Install Docker on Mac OS X 10.11.x

Since Docker is becoming more and more industry standard, I’m writing this post to install Docker on Mac OS X without using the installation package Docker Toolbox.

IMPORTANT: I recommend to use Docker for Mac.
At the time I wrote this post Docker for Mac was not out.

Why I don’t like using Docker Toolbox

I don’t like to use Docker Toolbox that much because;

  1. I don’t want to be forced to use VirtualBox, because VMWare Fusion and Parallels Desktop have a much better performance.
  2. The second thing I don’t like is that I need to download one large package (with VirtualBox shipped). I want to update my Docker stack with a few commands.
  3. There is no autoupdater for Docker Toolbox, if you want to update you need to check the download page to find out that they have released a new version.

Don’t get me wrong, I like the idea of Docker Toolbox. It’s great for developers who want to use an installation wizard. But if you’re like me, you may want to know how to install Docker without using an installation package.

If you already have Docker Toolbox installed, we’re first going to uninstall this. Run these commands in your Terminal:

# Download uninstaller from Docker toolbox Github
curl -o uninstall_dockertoolbox.sh https://raw.githubusercontent.com/docker/toolbox/master/osx/uninstall.sh
# Check if the downloaded file seems ok, never trust a bash script downloaded from the Internet! If it seems ok, run it.
chmod +x uninstall_dockertoolbox.sh && sudo ./uninstall_dockertoolbox.sh

Install Homebrew and Cask

Next install Homebrew (If you haven’t installed it yet). Installation details can be found on the homepage of Homebrew.

# Update brew
brew update
# Install Cask
brew tap caskroom/cask

Install Docker

# Install Docker
brew install docker
# Install Docker Machine
brew install docker-machine
# Install Docker Compose
brew install docker-compose

Since Docker does not run native on Mac OS X we need to create a Virtual Machine for that job. It will create a small Virtual Machine using Boot2Docker. So now you can choose which hypervisor you want to use.
I prefer VMWare fusion, but I’ll show you how to install on any Virtual Machine.

VMware Fusion

# Install Vmware Fusion
brew cask install vmware-fusion
# Create a new Virtual Machine for Boot2Docker
docker-machine create --driver=vmwarefusion default

Parallels Desktop

# Install Parallels Desktop
brew cask install parallels-desktop
# Install the Docker Machine drivers
brew install docker-machine-parallels
# Create a new Virtual Machine for Boot2Docker
docker-machine create --driver=parallels default

VirtualBox

# Create a new Virtual machine for Boot2Docker
docker-machine create --driver=virtualbox default
# Connect docker client and Docker Engine to the new created virtual Machine
docker-machine env default

After creating the Virtual Machine

# Configure your shell to use the new created Virtual Machine
eval $(docker-machine env default)
# Get the IP adres from the machine:
docker-machine ip default

That’s it! It’s that simple to install Docker with Docker Compose on Mac OS X!

Worth mentioning: I used “default” as my Virtual Machine name, but you can use any name you like, for example “devbox”.

docker-machine create --driver=vmwarefusion devbox
docker-machine env devbox
eval $(docker-machine env devbox)
docker-machine ip devbox

Updating your Docker installation

# Update homebrew
brew update
# First update VMWare Fusion, Parallels or VirtualBox.
brew cask update vmware-fusion
# Now upgrade all other Homebrew packages.
brew upgrade

Enjoy using containers with Docker!