I'm using gitlab CI runner to build a docker image and I want to push it to my private registry.
The CI runner is using docker:latest
and I mounted /var/run/docker.sock
into the container.
The docker login -u myuser -p mypass registry.mydomain.com:5000
works and it says login succeeded, but when I try to push the built image in the next command I get unauthorized: authentication required
.
Where does docker store the login to a registry? Is it even possible to push to a custom registry having a docker container, that mounts to hosts docker.sock
.
Steps to reproduce:
docker run -ti -v /var/run/docker.sock:/var/run/docker.sock docker sh
docker login -u username -p password registry.myhost.com:5000
docker build -t registry.myhost.com:5000/namespace/user:latest .
docker push registry.myhost.com:5000/namespace/user:latest
Docker stores login tokens to the registries at:
${HOME}/.docker/config.json
If you're running all of your commands as a single script from the same user, then perhaps there's a restrictive proxy or firewall, or the private registry is misconfigured in some way.