Build and push docker image, unauthorized: authentication required

docker

#1

Hello, I’m trying to build and push my container to a private registry. The following is what I’m seeing:

TAG=latest
docker login -u $DOCKER_USER -p $DOCKER_PASS my-registry.com
docker pull my-registry.com/my/container


Shell: /bin/bash -eo pipefail

Login Succeeded
Using default tag: latest
Pulling repository my-registry.com/my/container
unauthorized: authentication required
Exited with code 1

It works locally without issue and I’m not sure how to debug this; thanks.

Building the image works without issue but push/pull fails.


#2

Can you try docker -D pull for more debug information?


#3

Hey @rohara,

I modified the pull to docker -D pull my-registry.com/my/container got:

Login Succeeded
DEBU[0000] Trusting 168 certs                           
Pulling repository my-registry.com/my/container
unauthorized: authentication required
Exited with code 1

#4

Check ~/.docker/config.json after logging in to see what’s being stored. Does it reference the right registry?


#5

It looks fine to me:

{
	"auths": {
		"my-registry.com": {
			"auth": "{HASH}"
		}
	}
}

#6

I don’t know if this is relevant but this is being executed after:

- setup_remote_docker

I’m using - image: egyptianbman/docker-circleci-centos-basehttps://hub.docker.com/r/egyptianbman/docker-circleci-centos-base/https://github.com/egyptianbman/docker-circleci-centos-base/blob/master/Dockerfile


#7

That’s very odd… I haven’t seen this happen yet. I don’t have a fix.


#8

I stumbled on https://circleci.com/docs/2.0/private-images/ while googling and found the image used is docker:1.13.1-git. This works for me and my build is now passing.

I created my own image with docker installed because the other options I found when I searched weren’t auto triggering a build so they’d eventually get outdated. Having an official container works.

Thanks for helping me work through it!


#9