Skip to content

How to resolve unauthorized: unauthorized to access repository problem with docker

Problem

When we execute the docker push command like this:

Terminal window
[root@bswen-6 ~]# docker push 10.2.3.111:8080/argoproj/argocd:v1.8.3
The push refers to repository [1.2.3.111:8080/argoproj/argocd]
9e8889c68c29: Preparing
e2684c2e07a6: Preparing
9cb6851d8ac6: Preparing
0885361d274e: Preparing
beafdbd02907: Preparing
4bdb2d3f4802: Waiting
36b389f32a1a: Waiting
a5a93a6334d8: Waiting
e7a5d692dccd: Waiting
308d77bedb5c: Waiting
a3428c8ac191: Waiting
a971ff794527: Waiting
834f7927f44c: Waiting
ad50016551e3: Waiting
6863b9dc3d9d: Waiting
ce812d175010: Waiting
cb42413394c4: Waiting
unauthorized: unauthorized to access repository: argoproj/argocd, action: push: unauthorized to access repository: argoproj/argocd, action: push

we get this error:

Terminal window
unauthorized: unauthorized to access repository: argoproj/argocd, action: push: unauthorized to access repository: argoproj/argocd, action: push

The core error is: unauthorized to access repository.

Why does this error occur? The Docker repository URL is correct, and I am sure of it!

Environment

  • Docker 20.10.2

Reason

This error occurs because you have not correctly authenticated with your private Docker repository. You must log in to the Docker repository first before you can push your Docker image to it.

Solution

First, authenticate using the docker login command:

docker
[root@bswen-k8s-app5 ~]# docker login 10.2.3.111:8080
Username: bswen
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Input your username and password. If authentication is successful, you are ready to push your Docker image.

Next, push your Docker image to the repository:

docker
[root@bswen-k8s-app5 ~]# docker push 10.2.3.111:8080/argoproj/argocd:v1.8.3
The push refers to repository [1.2.3.111:8080/argoproj/argocd]
9e8889c68c29: Pushed
e2684c2e07a6: Pushing 256.2MB/532.7MB
9cb6851d8ac6: Pushed
0885361d274e: Pushed
beafdbd02907: Pushed
4bdb2d3f4802: Pushed
36b389f32a1a: Pushed
a5a93a6334d8: Pushed
e7a5d692dccd: Pushed
308d77bedb5c: Pushed
a3428c8ac191: Pushed
a971ff794527: Pushed
834f7927f44c: Pushed
ad50016551e3: Pushed
6863b9dc3d9d: Pushing 71.42MB/521.9MB
ce812d175010: Pushed
cb42413394c4: Pushing 64.05MB/69.24MB

It works!

Summary

The unauthorized to access repository error is a common issue when pushing Docker images to a private repository. The root cause is usually a lack of proper authentication. By using the docker login command to authenticate with the repository, you can resolve this issue and successfully push your images. Additionally, consider using a credential helper to securely store your login credentials.

Final Words + More Resources

My intention with this article was to help others who might be considering solving such a problem. So I hope that’s been the case here. If you still have any questions, don’t hesitate to ask me by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!