others-How to solve requested access to the resource is denied?

How to solve requested access to the resource is denied error when pushing docker images to registry?

Problem

When you want to push an docker image to harbor or other docker registries, you would get this error:

[root@k8s-test-113 ~]# docker push 10.1.2.112:8443/envoyproxy/envoy-alpine:latest
The push refers to repository [10.1.2.112:8443/envoyproxy/envoy-alpine]
5389ef4288ac: Preparing 
2edbab403b11: Preparing 
d7ae7175ca34: Preparing 
384cabecb0e8: Preparing 
d170a651c616: Preparing 
5216338b40a7: Waiting 
denied: requested access to the resource is denied

Solution

You should specify the repository name in the tag of the docker image, e.g.

Instead of this tag:

10.1.2.112:8443/envoyproxy/envoy-alpine:latest

You should use this tag:

10.1.2.112:8443/gcr.io/envoyproxy/envoy-alpine:latest

Because there is a repository in the your registry like this:

docker harbor

Other operations

You should make sure that you have logged in the harbor repo:

docker logout
docker login -u admin 10.1.2.112:8443

Login Succeeded