Cooking with Docker and CoreOS on OS X
This posts assumes some familiarity with Docker—it’s a practical guide to a workflow on OS X.
Docker is hot. It represents a significant addition to the second derivative of the state of our art. And while there are plenty of tutorials on using Docker floating around, none of them left me with all of the functionality I needed, or a clear picture of how to do real work. I have been frustrated, tickled, and tantalized. Docker, you were a real tease—until today.
When you’re finished, you should have a native docker client, container ports that are easily accessible via localhost, and the ability to edit files on live containers from the comfort of your own
The Docker Daemon: in CoreOS via Vagrant
We’ll edit the
Vagrantfile to setup an NFS share (for editing container files) and port forwarding (for visiting our beautiful applications via localhost):
Install the latest docker in the VM
At time of writing, this is necessary because the docker client is native to OS X only as of 0.8, and CoreOS is still running 0.7.5, which is not on speaking terms with its younger sibling.
Add a service for the downloaded docker:
Kill the 0.7.5 docker daemon and start 0.8:
If you make subsequent modifications to the new service file, you’ll need to restart it with a different incantation:
Something smells delicious…
Docker is served
docker run commands with a spring of
-v, and your containers will share files with your local file system via the vm.
There is one hiccough, which is that I get an error running a container with a volume if the volume directory already exists in the container, which it is wont to do if you’re maintaining a Dockerfile (which you should) and using the
ADD . /dir build strategy (which is good). This is, however, the approach explicitly proscribed and used by @jpetazzo, so I bet I’m doing something wrong, or there is a bug that will get fixed soon. (In the meantime, however, I haven’t found it problematic to mount the volume elsewhere.)
blog comments powered by Disqus