Compose comes with command completion for the bash and zsh shell.
Make sure bash completion is installed.
On a current Linux OS (in a non-minimal installation), bash completion should be available.
Place the completion script in /etc/bash_completion.d/
.
sudo curl -L https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
brew install bash-completion
.After the installation, Brew displays the installation path. Make sure to place the completion script in the path.
For example, when running this command on Mac 10.13.2, place the completion script in /usr/local/etc/bash_completion.d/
.
sudo curl -L https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose
Add the following to your ~/.bash_profile
:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
~/.bash_profile
or launch a new terminal to utilize completion.Run sudo port install bash-completion
to install bash completion.
Add the following lines to ~/.bash_profile
:
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi
You can source your ~/.bash_profile
or launch a new terminal to utilize completion.
Make sure you have installed oh-my-zsh
on your computer.
Add docker
and docker-compose
to the plugins list in ~/.zshrc
to run autocompletion within the oh-my-zsh shell. In the following example, ...
represent other Zsh plugins you may have installed.
plugins=(... docker docker-compose
)
Place the completion script in your /path/to/zsh/completion
(typically ~/.zsh/completion/
):
$ mkdir -p ~/.zsh/completion
$ curl -L https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose
Include the directory in your $fpath
by adding in ~/.zshrc
:
fpath=(~/.zsh/completion $fpath)
Make sure compinit
is loaded or do it by adding in ~/.zshrc
:
autoload -Uz compinit && compinit -i
Then reload your shell:
exec $SHELL -l
Depending on what you typed on the command line so far, it completes:
docker-compose scale
, completed service names automatically have “=” appended.docker-compose kill -s
completes some signals like SIGHUP and SIGUSR1.Enjoy working with Compose faster and with fewer typos!
fig, composition, compose, docker, orchestration, cli, reference
© 2019 Docker, Inc.
Licensed under the Apache License, Version 2.0.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.
Docker, Inc. and other parties may also have trademark rights in other terms used herein.
https://docs.docker.com/compose/completion/