Docker on your Mac using Vagrant

The first time I tried docker I used boot2docker without complete knowledge of it. The idea behind boot2docker is really quite clever: since we can’t run docker natively on Mac, we install a bare-bones Linux VM that can run docker, and then we communicate with it using a docker client running on our host.

After some initial tests I started looking for a different solution considering that I already installed Vagrant on my machine.

This guide explain how to use docker on mac using Vagrant with VirtualBox or Parallels as provider without installing boot2docker.

Once you’ve completed all these steps, you should have the Docker client installed and a VM capable of starting Docker containers. To test it out, try the command docker run hello-world from your host:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
a8219747be10: Pull complete
91c95931e552: Already exists
hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd18681cf5daeb82aab55838d
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
...

Good Dockering! 😉

Tip

In some case you can encounter this error “Error response from daemon: client and server don’t have same version”. To solve this problem install older or newer Docker version on your machine.