Skip to content

Instantly share code, notes, and snippets.

@maskshell
Forked from rkuzsma/docker-bash-completion.md
Last active October 30, 2018 06:59
Show Gist options
  • Save maskshell/cf8a9acac178aed6837c3a4eaff1848e to your computer and use it in GitHub Desktop.
Save maskshell/cf8a9acac178aed6837c3a4eaff1848e to your computer and use it in GitHub Desktop.
How to configure Bash Completion on Mac for Docker and Docker-Compose

How to configure Bash Completion on Mac for Docker, Docker-Machine and Docker-Compose

Run:

brew install bash-completion

Add the following lines to your ~/.bash_profile:

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

Assuming you're using "Docker for Mac" from store.docker.com, it's idea to use the bash completion files that come with it. The Docker for Mac client keeps itself up to date and comes with the latest completion changes, which are often. Also, the Docker for Mac method includes docker-machine's completion too. Read more at their docs site or just see the below:

# After you've installed Docker for Mac and the brew bash completion steps
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion /usr/local/etc/bash_completion.d/docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion /usr/local/etc/bash_completion.d/docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion /usr/local/etc/bash_completion.d/doc

Logout/login to your shell, or source ~/.bash_profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment