How to resolve unauthorized: unauthorized to access repository problem with docker
Problem
When we execute the docker push
command like this:
[root@bswen-6 ~]# docker push 10.2.3.111:8080/argoproj/argocd:v1.8.3The push refers to repository [1.2.3.111:8080/argoproj/argocd]9e8889c68c29: Preparinge2684c2e07a6: Preparing9cb6851d8ac6: Preparing0885361d274e: Preparingbeafdbd02907: Preparing4bdb2d3f4802: Waiting36b389f32a1a: Waitinga5a93a6334d8: Waitinge7a5d692dccd: Waiting308d77bedb5c: Waitinga3428c8ac191: Waitinga971ff794527: Waiting834f7927f44c: Waitingad50016551e3: Waiting6863b9dc3d9d: Waitingce812d175010: Waitingcb42413394c4: Waitingunauthorized: unauthorized to access repository: argoproj/argocd, action: push: unauthorized to access repository: argoproj/argocd, action: push
we get this error:
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:
[root@bswen-k8s-app5 ~]# docker login 10.2.3.111:8080Username: bswenPassword:WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://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:
[root@bswen-k8s-app5 ~]# docker push 10.2.3.111:8080/argoproj/argocd:v1.8.3The push refers to repository [1.2.3.111:8080/argoproj/argocd]9e8889c68c29: Pushede2684c2e07a6: Pushing 256.2MB/532.7MB9cb6851d8ac6: Pushed0885361d274e: Pushedbeafdbd02907: Pushed4bdb2d3f4802: Pushed36b389f32a1a: Pusheda5a93a6334d8: Pushede7a5d692dccd: Pushed308d77bedb5c: Pusheda3428c8ac191: Pusheda971ff794527: Pushed834f7927f44c: Pushedad50016551e3: Pushed6863b9dc3d9d: Pushing 71.42MB/521.9MBce812d175010: Pushedcb42413394c4: 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!