Ensuring docker-machine is running

When developing using docker on OS X, you’ll currently1 have to use docker-machine to spin up a virtual machine that is actually running the docker containers. Running a virtual machine takes up a bit more in the way of resources than just the docker containers, so if you’re not actually developing at the moment, it’s helpful to be able to start up the virtual machine only when you need it.

The current way I have to do that:

$ docker-machine start default
$ eval $(docker-machine env default)

What’s worse, the latter command has to be run for every shell that you start up. It’s by no means a hard pair of commands and you could easily wrap them in an alias or put them in your .profile equivalent (which is what I used to do). But unfortunately, I found a completely unrelated bug in tmuxp: if the shell takes too long to start up, tmuxp essentially won’t work. The above eval command took long enough to hit this limit.

read more...