Gitlab Registry and Docker Compose

Reconciling that Compose runs as root and Gitlab Registry doesn't allow anonymous logins.
September 23, 2016
ansible docker gitlab registry compose

If you’re like most Docker users, you’ve put your SSH user into the docker group so that you can run docker commands without needing to use sudo. This is great.

If you were running a v1 registry, you’re probably used to having something like the following as a container name:

registry.example.com:5000/user/container

This worked. You could run docker and docker-compose commands. So could root, so when you rebooted, if you’re firing off Compose via Upstart or the like, the anonymity available in the v1 registry meant that your Docker host could pull the containers and launch them.

Fast forward to Gitlab Registry (and maybe also the general Docker v2 Registry, though I don’t know for sure). There’s no more anonymity, so you need to run docker login registry.example.com as both your own user and as root. This creates ~/.docker/config.json with the appropriate authentication lines.

Without this, you’ll reboot your system and find that Docker can’t fetch any of your containers from the registry, leaving you high and dry.