Use Docker Machine with Mounts from a Second Drive

Last weekend I fiddled with some HipChat data and ElasticSearch and Kibana a bit. The Docker ELK stack is a great way to use the latter locally. I’m using it already on my work machine, so I happily checked it out and ran docker-compose up … only to get some odd error on my private Mac now:

System error: not a directory

What? I check my work machine: No problems there, same versions of all components. Odd. Turns out, I’m not the first one to encounter this. It seems to be the mount of the Kibana-config-file which causes this issue.

No “easy” fix in these links, so I jumped in and added COPY statements to the Dockerfile. Rebuild the image over and over till everything worked the way I wanted it to work. With each rebuild I tried to get closer to the problem or find a workaround not involving copying on build.

In the end it was StackOverflow to the rescue: Turns out docker-machine only mounts a main dir into the machine, making all path references fail which are not beneath this mount. In my case (on a Mac with a second HDD) it only mounted /User, but my project files were in /Volumes/HDD. Hence the reference in docker-compose couldn’t be resolved and resulted in the error above.

The solution:

  • Manually add the second drive as a Shared Drive in VirtualBox
  • Mount the directory in your docker-machine with the fullpath as it has on your machine (e.g. /Volumes/HDD/)

Fairly easy once I figured it out and while I cost me half a Sunday, I know a fair bit more about the underpinings of docker-machine and docker-compose. See Andi’s StackOverflow answer for all specifics.