I used to use
boot2docker on OSX, but when I came to install it on my new machine I noticed that it was deprecated and that it should be replaced with the Docker Toolbox.
brew cask install dockertoolbox
The first thing the Docker Toolbox will try to do is update Virtualbox to the latest version. If this doesn’t work, you probably have Virtualbox machines running that can’t be automatically shut down (in my case, I needed to provide my
sudo password for the
vagrant-hostsupdater plugin). The error message will look something like this:
==> Failed command: ["/usr/bin/sudo", "-E", "--", "/usr/sbin/installer", "-pkg", "#&";, "-target", "/"] ==> Output of failed command: 6513 ?? 0:20.04 /Applications/VirtualBox.app/Contents/MacOS/VBoxSVC --auto-shutdown 6601 ?? 10:43.73 /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless --comment joindin-vm_joindin_1443821732951_46821 --startvm c02e4c4e-c423-432f-9ab0-c8fa732b1080 --vrde config
I use Vagrant so I listed all my running machines using
$ vagrant global-status and stopped them by hand. After doing this I re-ran
brew cask install dockertoolbox and it went through fine.
Once it’s all installed, we need to create a VM to run docker in. If you don’t already have it locally, this will download a small
boot2docker iso (not to be confused with the boot2docker tool).
docker-machine create --driver virtualbox docker
Once this is running, you can provide the environment to the
docker utility via
env variables just like we did with
docker-machine env docker
We can load those details into our session with the following line:
eval “$(docker-machine env docker)”
Then, fingers crossed we should be able to run the “Hello World” container
docker run hello-world
If you can do that, congrats! You’ve just set up Docker on OSX with
Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter