Docker on Linux works by using native Linux virtualization facilities like cgroups and namespaces which isolates resources like CPU, memory, I/O etc. On Mac and Windows, till date, Docker would install Docker Toolbox which is all the docker commands and VirtualBox. During installation Docker also installs a “default” VirtualMachine running the boot2docker Linux distribution, which is managed by the docker-machine command. All docker images and container are spun up in this Linux VM. So a Linux Virtul Machine running on VirtualBox or some other provider was pretty much necessary to run Docker on Mac and Windows…..until now.
Introducing Docker for Mac
With Docker 1.11.0 Docker will run natively on Mac and Windows. Docker will be supported on Windows 10 running Hyper-V and Mac OS X 10.10.3 or higher using xhyve. I managed to get my paws on the private beta which is currently by invite only. Once you get the invite, you get sent a code. You can download the installer and install the binaries from the beta site, however once you try to run it it asks you to enter your invite code. Once you enter your invite code your installation is activated.
The installer asks for priviledged access since it creates links from /Applications into /usr/local. Any previous installation of Docker will be overwritten at this point.
If you had a previous installation of Docker and a virtual machine called “default”, at this point the installer will offer to migrates all your images and containers to the new installation.
Depending on your Docker use and the number of images and containers you have this migration can take quite some time. So grab a coffee.
And finally after about 10 minutes we are done.
After you click OK, a tiny little whale show up in your task bar with the message shown below.
You can click the tiny whale any time to open the settings.
Clicking on Dashboard says a native dashboard is coming soon and for now we can use Kinematic.
Similarly clicking on logs suggests using the logs utility from Utilities or checking them out from the command line.
There are various differences between Docker Toolkit (The Old Docker) and Docker for Mac. During the installation, Docker for Mac creates a brand new virtual machine called default under the xhyve virtualization framework. Your existing default VM under VirtualBox is left untouched, however it does offer to migrate your containers and images from the previous default VM to the new default. This is the migration that took 10 minutes. Docker for Mac does not use docker-machine command to manage the new default vm. Nor does it migrate any other virtual machines you may have created using the docker-machine command. Before you can start using Docker for Mac, you should unset any command line Docker variables you have set so that you don’t accidentally connect to your previous Docker installation.
You can unset your Docker variables by running the command
This way you can rest assured you are using Docker for Mac.
Docker for Mac and Docker Toolbox can coexist on the same machine. This means you can use Docker for Mac and still use docker-machine to manage your old machines. The only catch is your docker client and your docker engine should be the same version. Then you can simply run the standard eval command to connect to the docker machine of your liking.
eval $(docker-machine env default)
Besides being native to Mac OS X, Docker for Mac brings a few features to the party.
- You can now run containers for different Linux archicture natively such as arm, mips, ppc64l2 etc. due to Docker for Mac’s support for binfmt_misc. This will only work if the said container has the appropriate qemu binary.
- Docker for Mac comes with exclusive filesystem support for Mac called osxfs. Docker promises this will provide a close-to-native file system experince on Mac. This means much of the filesystem that is avaliable to the user will also be avaliable to the containers and all of the -v binds should work (haven’t tried them all yet). File system events are also supported and passed on to containers. And a host of other features.
- Expermintal features which come with warning “Here be dragons !”. These pretty much allow you to tweak the inner workings of the docker driver and set various options like networking, cpu, ports, hostname etc. I think I am going to have fun with these.
This is the very first native beta release of Docker for Mac and Windows and already brings huge performance benifits. In the next article I will put Docker for Mac through the paces and try out all the new features including Multi-CPU Architecture Support, the new osxfs, and other experimental features exclusive to Mac. I will also try to get my hands on a Windows 10 box to try the Windows 10 build so stay tuned.