boot2docker on OS X
This is how you can autorun
boot2docker on boot, so that you can use
docker as you would on Linux, without ever* knowing that the daemon's not running locally.
- Install VirtualBox &
- Create a startup script with Automator
- Put in
/usr/local/bin/boot2docker up && /usr/local/bin/boot2docker shellinit > ~/.boot2docker-shellinit.sh
echo "export DOCKER_IP=$(boot2docker ip 2>/dev/null)" >> ~/.boot2docker-shellinit.shif you want the non-standard but very-convenient
DOCKER_IPenv-var as well (thanks for the suggestion @city41!)
- Update your
.profileor equivalent file with
- Reboot your machine
$ docker psinto a terminal
- PROFIT from a native-Linux-like Docker experience
One caveat: if the env vars change from their previous values (usually they don't) and you're quick enough to open your terminal before the Automator task finishes (usually you aren't), your shell will get stale env vars. In that case just wait a few seconds more and open a new terminal.
*) I lied a bit: Any ports you expose still won't be exposed on localhost, but instead at
$DOCKER_HOST. Also, only shares from
/Users work automagically, anything else you have to share manually with VirtualBox. Oh well, close enough.