October 19, 2017

Get bash autocompletion working for docker cli on a mac

First install the following formulas:


You can find all my latest posts on medium.
brew install bash-completion
brew cask install docker

Next via the gui launcher, find the docker icon and launch it, then follow the prompts. Then restart your bash terminal. Now run the following command to create a few symbolic links:

ln -s /Applications/ /usr/local/etc/bash_completion.d/docker
ln -s /Applications/ /usr/local/etc/bash_completion.d/docker-machine
ln -s /Applications/ /usr/local/etc/bash_completion.d/docker-compose

Then restart the bash terminal. Therefore running the above ln commands resulted in the following files being created:

$ pwd
$ cd /usr/local/etc/bash_completion.d/
$ ll | grep docker
-rw-r--r--  1 schowdhury  admin     15 19 Oct 11:18 docker
-rw-r--r--  1 schowdhury  admin     15 19 Oct 11:18 docker-compose
-rw-r--r--  1 schowdhury  admin  10347 19 Oct 11:18 docker-machine
-rw-r--r--  1 schowdhury  admin   1469 19 Oct 11:19 docker-machine-prompt
-rw-r--r--  1 schowdhury  admin   1525 19 Oct 11:18 docker-machine-wrapper


Add Docker autocompletion in your shell{:rel=nofollow}
Installing Docker Bash completion