Awhile ago I started exploring what containers were and how to wrap my head around them to do deployments.
I pointed my browser to Docker’s Mac OS X installation web page which read something like this:
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. Boot2Docker includes a VirtualBox VM, Docker itself, and the Boot2Docker management tool.
Since I already have another VM environment installed (aka VMWare Fusion) and also Vagrant, I wasn’t too keen to install VirtualBox just for the exploratory exercise.
The solution was rather simple. Use Vagrant to start a Linux Box and then Install Docker in it.
You can use the following Vagrantfile as an example.
The Vagrantfile refers to bootstrap_docker.sh. This is a simple bash script that runs after Vagrant boots your VM and then installs Docker.
Copy and paste the code into the Vagrantfile and bootstrap_docker.sh in a new directory then run Vagrant.
$ vagrant up $ vagrant ssh
Once you ssh into the box test your Docker installation:
$ sudo docker run -i -t ubuntu /bin/bash
This will download the Ubuntu container and start a shell session on it.
That’s it!
Time to experiment with more containers.