How I install and configure Docker for my Mac via Homebrew29 Jan 2019
This is the best way I can come up with to install Docker on my Mac. I never liked manually downloading the “.dmg” file and then moving it to the Applications directory. I will be sharing in this post how I installed it via Homebrew while also configuring bash completion for Docker.
Steps to install and configure Docker:
Homebrew is a package manager for Mac and has always been my preferred way to install my tools because I can integrate it with my setup scripts. To install it execute
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
then install Homebrew Cask which is an extension of Homebrew. It makes the installation of large binaries and graphical applications simpler.
brew tap caskroom/versions
To install Docker via Homebrew run
brew cask install docker
then after installation run
to confirm its installation.
Install bash completion via Homebrew.
brew install bash-completion
Create symlinks for Docker’s completion on Bash.
etc=/Applications/Docker.app/Contents/Resources/etc ln -s $etc/docker.bash-completion $(brew --prefix)/etc/bash_completion.d/docker ln -s $etc/docker-machine.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-machine ln -s $etc/docker-compose.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-compose
Add this line to your ~/.bash_profile.
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
Apply the changes by running
Thats it! Now you have installed Docker while also enabling completion for Bash. If you know a better way to install it please don’t hesitate to comment below.