others-how to solve unauthorized: unauthorized to access repository problem with docker ?

Problem

When we do docker push command like this:

[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 :

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

The core error is : fatal: unauthorized to access repository

Why do this error happen? The docker repository url is correct, I am sure!!!

Environment

  • docker 20.10.2

Reason

This error happens because you have not correctly authenticated by your private docker repository, you should login the docker repository at first, then you can push your docker image to the repository.

Solution

First, authenticate with the docker command:

[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 all pass, then you are authenticated.

Then push your docker image to the repo:

[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!