With a few tiny tweaks to your Mac, you can connect with Docker containers running on Weave Net and Docker for Mac, without exposing ports on the Docker host – which is great for testing and debugging during application development.
Have you heard of? You probably have—everybody’s talking about it. Even my dad’s like, “what’s Docker? I saw someone twitter about it on the Facebook. You should call your mom.” Docker is a program that makes running and managing super easy.
It has the potential to change all aspects of server-side applications, from development and testing to deployment and scaling. It’s pretty cool. Recently, I’ve been working through. It’s a top notch book and I highly recommend it, but I’ve had some problems running the examples on OS X. After a certain point, the book assumes you’re using Linux and skips some of the extra configuration required to make the examples work on OS X. This isn’t the book’s fault; rather, it speaks to underlying issues with how Docker works on OS X.
This post is a walkthrough of the issues you’ll face running Docker on OS X and the workarounds to deal with them. It’s not meant to be a tutorial on Docker itself, but I encourage you to follow along and type in all the commands. You’ll get a better understanding of how Docker works in general and on OS X specifically. Plus, if you decide to dig deeper into Docker on your Mac, you’ll be saved hours of troubleshooting. Don’t say I never gave you nothing. First, let’s talk about how Docker works and why running it on OS X no work so good.
How Docker Works Docker is a client-server application. The Docker server is a daemon that does all the heavy lifting: building and downloading images, starting and stopping containers, and the like. It exposes a REST API for remote management. The Docker client is a command line program that communicates with the Docker server using the REST API.
You will interact with Docker by using the client to send commands to the server. The machine running the Docker server is called the Docker host. The host can be any machine—your laptop, a server in the Cloud™, etc—but, because Docker uses features only available to Linux, that machine must be running Linux (more specifically, the Linux kernel).
Docker on Linux Suppose we want to run containers directly on our Linux laptop. Here’s how it looks: Docking on Linux The laptop is running both the client and the server, thus making it the Docker host. Docker on OS X Here’s the thing about OS X: it’s not Linux. It doesn’t have the kernel features required to run Docker containers natively. We still need to have Linux running somewhere. Boot2docker is a “lightweight Linux distribution made specifically to run Docker containers.” Spoiler alert: you’re going to run it in a VM on your Mac. Here’s a diagram of how we’ll use boot2docker: Docking on OS X We’ll run the Docker client natively on OS X, but the Docker server will run inside our boot2docker VM.
This also means boot2docker, not OS X, is the Docker host, not OS X. Let’s install dat software. Installation Step 1: Install VirtualBox Go and do it.
You don’t need my help with that. Step 2: Install Docker and boot2docker You have two choices: the offical package from. I prefer homebrew because I like to manage my environment from the command line. brew update brew install docker brew install boot2docker Step 3: Initialize and start boot2docker First, we need to initialize boot2docker (we only have to do this once): boot2docker init 2014/08/21 13:49:33 Downloading boot2docker ISO image. 2014/08/21 13:49:50 Done. Type `boot2docker up` to start the VM.
Next, we can start up the VM. Do like it says: boot2docker up 2014/08/21 13:51:29 Waiting for VM to be started. 2014/08/21 13:51:50 Started. 2014/08/21 13:51:51 Trying to get IP one more time 2014/08/21 13:51:51 To connect the Docker client to the Docker daemon, please set: 2014/08/21 13:51:51 export DOCKERHOST=tcp://192.168.59.103:2375 Step 4: Set the DOCKERHOST environment variable The Docker client assumes the Docker host is the current machine. We need to tell it to use our boot2docker VM by setting the DOCKERHOST environment variable: export DOCKERHOST=tcp://192.168.59.103:2375.
With a private registry, I cannot pull images because certains image layers fail to download. The pattern seems to be that this happens with larger, 50MB sized layers. It shouldn't be a registry neither network problem as colleagues with other systems manage to get these images.