Up and Running With docker-osx-dev
In this post I’ll try to describe the process I went through to get the docker-osx-dev tooling in place. My environment is (or was) a bit messy. I decided to try this tool after reading the A productive development environment with Docker on OS X article.
I had all sorts of tools in all sorts of languages and frameworks installed on my computer.
Short description
- Install Homebrew v 0.9.5
- Install Docker v 1.9.1
- Install docker-osx-dev
- Install boot2docker
- Install Docker Toolbox v 1.9.1b
- Install VirtualBox v 5.0.10
The details
When I attempted to run the docker-osx-dev install command I received a bunch of permission errors. After searching I couldn’t find a solution. So I decided to uninstall my ancient brew installation.
After the script completed I had to manually uninstall some additional directories.
I then ran the brew installer:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Next I re-ran the docker-osx-dev install script and received the following error:
$ docker-osx-dev install
2015-12-01 22:38:29 [ERROR] Failed to install dependency Cask. Check the log output above for reasons.
Tens of minutes of searching later I hadn’t find a solution, so I just re-ran the install script and it seems to have worked better the second time, in fact it worked right up until the next error:
$ docker-osx-dev install
...
WARNING: The 'boot2docker' command line interface is officially deprecated.
Please switch to Docker Machine (https://docs.docker.com/machine/) ASAP.
Docker Toolbox (https://docker.com/toolbox) is the recommended install method.
error in run: Failed to initialize machine "boot2docker-vm": exec: "VBoxManage": executable file not found in $PATH
Following the suggestion I unsintalled boot2docker
curl https://raw.githubusercontent.com/boot2docker/osx-installer/master/uninstall.sh | sudo bash
Then installed the [Docker Toolbox](). After installation I re-ran the docker-osx-dev install and realized the the warning was coming from the boot2docker utility, and that it appears to have broken the docker-osx-dev run (It didn’t re-installed boot2docker).
I then re-installed boot2docker using the installer package.
It almost worked this time. Everything seems to have completed except modification of the ~/.bashrc script.
The installer added the following error into my ~/.bashrc:
2015-12-01 23:52:42 [ERROR] Unexpected entry from boot2docker shellinit: set -x DOCKER_HOST tcp://192.168.59.103:2376
I assume this issue is caused by the fact that I run fish as my primary shell.
So I ran the shell init manually:
$ boot2docker shellinit
and manually added the lines to my ~/.bashrc:
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/bbabb/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
and the following to my ~/.config/fish/config.fish:
set -x DOCKER_HOST tcp://192.168.59.103:2376
set -x DOCKER_CERT_PATH /Users/bbabb/.boot2docker/certs/boot2docker-vm
set -x DOCKER_TLS_VERIFY 1
I then tried it out by by using the example provided on the Docker Compose example on the docker-osx-dev page:
$ mkdir example && cd example
$ touch docker-compose.yml
$ mkdir foo
the updated the docker-compose.yml
file with the following:
web:
image: training/webapp
volumes:
- ./foo:/src
ports:
- "5000:5000"
db:
image: postgres
Then ran:
$ docker-osx-dev
in one terminal, and:
docker-compose up
in another. After the command completed I browsed to http://dockerhost:5000/
,
and recevied:
Hello world!
Seems like it’s working. Overall this took about 3 hours to get running.
If for some reason the docker-osx-dev
doesn’t include the /etc/hosts
entry, try running:
echo $DOCKER_HOST | sed "s/tcp:\/\///" | sed "s/:[0-9]*//" >> /etc/hosts