A simple wrapper arond docker-compose
for local docker development inspired by https://github.com/shipping-docker/vessel.
I like to write as less possible. Especially for my local toolchain. As I often use Laravel one of my favourite shortcuts is a
for php artisan
.
So I created the d
.
Unlike Vessel, I needed a wrapper that could be used in any project, and not just Laravel.
Download using your favorite command:
curl -sL https://gist.githubusercontent.com/okaufmann/64c4273287b618270bf4bf9451393b53/raw/d -o d
# or
wget https://gist.githubusercontent.com/okaufmann/64c4273287b618270bf4bf9451393b53/raw/d -qO d
Then make it executable with chmod +x d
Alias
I recommend the following function in your .bashrc or .zshrc so you can just type d
over ./d
:
function d() {
command ./d "$@"
}
You can paste the following bash code to temporarily enable the alias:
function d() {
command ./d "$@"
}
export -f d
The d
searches for the file docker/local/docker-compose.yml
. There should be at least one service called app
in it.
The d
is used to forward all commands to the container. composer install
or further commands can be executed simply by using
d composer install
Unfortunately, there are a few commands that can be both Linux and docker-compose commands such as rm, ps, kill, top, exec, help
.
To execute these commands, you can simply mark them with a leading dot so that they are treated as docker-compose *
commands.
For example, to delete a container, you can use
d.rm app
To forward commands to a container other than app
, you can overwrite the name with the environment variable C
.
An example:
C=redis d bash