Command-line completion

Docker Machine comes with command completion for the bash and zsh shell.

Installing Command Completion


Make sure bash completion is installed. If you are using a current version of 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/ as follows:

  • On a Mac:

    sudo curl -L -o `brew --prefix`/etc/bash_completion.d/docker-machine
  • On a standard Linux installation:

    sudo curl -L -o /etc/bash_completion.d/docker-machine

Completion is available upon next login.


Place the completion script in a completion directory within the ZSH configuration directory, such as ~/.zsh/completion/.

mkdir -p ~/.zsh/completion
curl -L > ~/.zsh/completion/_docker-machine

Include the directory in your $fpath, by adding a line like the following to the ~/.zshrc configuration file.

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 completes:

  • commands and their options
  • container IDs and names
  • image repositories and image tags
  • file paths

Where to go next

machine, docker, orchestration, cli, reference