Skip to content

Latest commit

 

History

History
78 lines (50 loc) · 2.85 KB

completion.md

File metadata and controls

78 lines (50 loc) · 2.85 KB
description keywords title
Compose CLI reference
fig, composition, compose, docker, orchestration, cli, reference
Command-line completion

Compose comes with command completion for the bash and zsh shell.

Installing Command Completion

Bash

Make sure bash completion is installed. If you use a current Linux in a non-minimal installation, bash completion should be available. On a Mac, install with brew install bash-completion

Place the completion script in /etc/bash_completion.d/ (/usr/local/etc/bash_completion.d/ on a Mac), using e.g.

curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

Then add the following to your ~/.bash_profile

if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi

You can source your ~/.bash_profile or launch a new terminal to utilize completion.

MacPorts Bash Completion

If you're using MacPorts you'll need to slightly modify your steps to the following Run sudo port install bash-completion to install bash completion

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.

Zsh

Place the completion script in your /path/to/zsh/completion, using e.g. ~/.zsh/completion/

$ mkdir -p ~/.zsh/completion
$ curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose

Include the directory in your $fpath, e.g. 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

Available completions

Depending on what you typed on the command line so far, it will complete

  • available docker-compose commands
  • options that are available for a particular command
  • service names that make sense in a given context (e.g. services with running or stopped instances or services based on images vs. services based on Dockerfiles). For docker-compose scale, completed service names will automatically have "=" appended.
  • arguments for selected options, e.g. docker-compose kill -s will complete some signals like SIGHUP and SIGUSR1.

Enjoy working with Compose faster and with less typos!

Compose documentation