Docker is an amazing platform which can help you setup different environments to run or test your applications, or just quickly get started with some software.

It is a container virtualization technology that runs your application in very lightweight containers, similar to regular virtual machines. However, it is much more efficient in terms of resources needed to run applications.

In fact, this website is running inside a Docker container.

Because the Docker daemon uses Linux-specific kernel features, you can't run Docker natively in OS X. Instead, you must install the Boot2Docker application. The application includes a VirtualBox Virtual Machine (VM), Docker itself, and the Boot2Docker management tool.

So, since Docker is not supported direcly on OS X, docker itself will be run inside a virtualbox vm, from your terminal. The lightweight virtualbox vm we will run, is Boot2Docker.

Installing Boot2Docker

Their Boot2Docker all-in-one installer can also install virtualbox if you don't already have it installed.

Download and install Boot2Docker from their github page:
Download and install the Boot2Docker-1.6.0.pkg file.

Then to download and initialize the Boot2Docker vm, start the Boot2Docker application in OS X.

This will start the virtualbox vm, and display three environment variables that you should set in your shell, to tell docker where it should run (inside the vm, not on your OS X host).

It will look something like:

To connect the Docker client to the Docker daemon, please set:
    export DOCKER_HOST=tcp://
    export DOCKER_CERT_PATH=/Users/username/.boot2docker/certs/boot2docker-vm
    export DOCKER_TLS_VERIFY=1

You can either run and export the variables in your current shell, or set them in for example ~/.zshenv since I use the z shell.

To run the Boot2Docker vm:

boot2docker up

You can now open virtualbox, and see the tiny vm running:

To stop the boot2docker vm, just run: boot2docker down.

Checking the installation

Then, to verify your installation, you can run boot2docker -v and docker -v to see that the command line utilities are working.

And you can run docker run hello-world which starts a simple container, that just outputs "Hello from Docker."

You should now be able to start developing and trying out docker!

Upgrading Boot2Docker

If you want to upgrade your Boot2Docker image to a newer version, you can always run:

boot2docker stop 
boot2docker download 
boot2docker up

Have you been using Docker for something? Please let me know in the comments.