I am attempting to have CircleCI automatically build and push a docker container to a private repository using these steps:
setup_remote_docker
docker login “<Private Registry>” -u “<Username>” -p “<Password>”
docker build --tag <Private Registry>/<Container Name>:<Container Version> .
docker push <Private Registry>/<Container Name>:<Container Version>
Login reports success, as does build, however push fails with an ‘unauthorized: authentication required’ error. I can also see that ‘~/.docker/config.json’ is correct.
I’m assuming this is because build and push are run in the context of the remote docker environment while login is only run in the context of my primary container.
Is there a way to get authentication working in the remote docker environment?
I had a look at the ‘Using Private Images’ help document but that only covers pulling from a private repository not pushing. I did attempt to put in authentication details that way but doing so prevented me from being able to pull ‘Docker’ as my primary container.