Docker, Mac/OSX, xhyve: Modify Container’s HostConfig

Hello Friends – Today I wanted to do some reorganization to my docker containers on my development box where I use Docker, Mac/OSX, xhyve for development. It was really very simple – I wanted to move my containers under a local directory (same as the namespace I like to use: sab).

…Leads to Problems!

You see the problem? It’s the reference to the old mount location. Now I could simply recreate the container (I have a Dockerfile and an automated init script that gets loaded from my local Git repo), but I realized that with the Integrated Docker for Mac/OSX which I’m using – I couldn’t easily get to the containers location where the JSON descriptor files are stored.

Docker, Container Metadata, and xhyve

Docker stores container metadata (depending on your backing filesystem) in a well-known location: /var/lib/docker/containers/[CONTAINER_ID]/ under the files config.v2.json and / or hostconfig.json. Since I moved my folders around on the Docker host, I need to update these files. This is simple on Linux – see this reference on modifying container options. And on “classic” Docker integrated with VirtualBox it’s still easy; you simply connect to the VirtualBox docker-machine VM (normally just called “default“) and we can get to the filesystem as we would on a native Linux installation of Docker.

However – there is one problem. I’m using the New Docker / xhyve Integration which eliminates the need for VirtualBox, docker-machine, or any of that cruft. But the question I had – how do I get to the lightweight Alpine Linux which Docker runs as an xhyve process?

ps and screen to the Rescue

The first thing I did was to learn how this xhyve integration works. I was half-expecting to find some CLI tools similar to virsh or esxcli but xhyve seems to work differently. Take a look at ps output:

There’s a great resource on Inside Docker / xhyve Integration which you can read up on, but to me the key points are the references to hyperkit (promising!) and the references to the folder /Users/l.abruce/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux – there are five of those references.