Thursday, January 29, 2015

Getting Docker to work on OS X

Chris Jones has an excellent resource on getting started with Docker on MAC OS X. You can access it here:
http://viget.com/extend/how-to-use-docker-on-os-x-the-missing-guide

My only deviation in the above guide is to install boot2docker from here:
https://github.com/boot2docker/osx-installer/releases

Everything else should work fine for you.

Accessing insecure private repos:

I have had some issues accessing insecure docker registries. The error is usually something like this:
laptop-rmenezes:$ docker push dockerregistry.dynprod.roger-menezes.net:7001/minions_ubuntubase-x86_64-20140910-ebs

2014/11/07 16:06:17 Error: Invalid registry endpoint https://dockerregistry.dynprod.roger-menezes.net:7001/v1/: Get https://dockerregistry.dynprod.roger-menezes.net:7001/v1/_ping: tls: oversized record received with length 20527. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry dockerregistry.dynprod.roger-menezes.net:7001` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/dockerregistry.dynprod.roger-menezes.net:7001/ca.crt

The fix over there is change the following file inside the boot2docker vm:
/var/lib/boot2docker/profile

boot2docker ssh
sudo vi /var/lib/boot2docker/profile

You need to add the following line to this fine:
EXTRA_ARGS="  --insecure-registry dockerregistry.eu-west-1.dyntest.roger-menezes.net:7001 --insecure-registry dockerregistry.dynprod.roger-menezes.net:7001  "

The above is an example that you can add multiple registries the above format.

Then you just need to do:
boot2docker up
boot2docker down

=============

Running a Docker command:
sudo docker run -v /mnt/data:/data -e "ENVIRONMENT=prod" -m 39g  d34ca1989ab7 /apps/python/bin/JobRunner.py  --config params.email=rmenezes@chakde.com

-v is used to mount a Machine directory onto a docker directory.
-e is used to pass environment variables.
-m tells how much memory to use
d34ca1989ab7 is the image id
the rest is the command