« »

A development v2 Docker Registry on Docker for Mac

Monday, 25 April 2016

Update (2016-04-25): I use a json command below that you can install via npm install -g json. See https://trentm.com/json/.


I got a key to the beta Docker for Mac recently and I’m working at updating Joyent’s node.js Docker Registry client for some recent Docker Distribution changes. I wanted to play around with a local registry running in my Docker for Mac. This post shows how.

With Docker on Linux a local dev registry container would be on locahost. The Docker Engine special cases registries on “localhost”, treating them as “insecure”, meaning it uses http for access and avoiding the need for you to setup a TLS proxy and certs. The way to do that for a registry not on localhost is to use docker daemon --insecure-registry=.... But how to set that on Docker for Mac? That was the only (small) hurdle.

Start a v2 registry:

docker pull registry:2
docker run --name reg2 -d --restart=always -p 5000:5000 registry:2

Get the registry container’s host and port:

$ docker port reg2
5000/tcp -> 192.168.64.2:5000

Use the Docker-for-Mac config tool “pinata” to set insecure-registries:

cd /Applications/Docker.app/Contents/Resources/bin
./pinata.bin get daemon \
    | json -e 'this["insecure-registries"] = ["192.168.64.2:5000"]' -0 \
    | ./pinata.bin set daemon -

Now you should be able to push an image to it:

docker pull alpine:latest
docker tag alpine:latest 192.168.64.2:5000/alpine:latest
docker push 192.168.64.2:5000/alpine:latest

Tagged: docker, programming