docker push 报错:unauthorized: unauthorized to access repository: library/xx处理方法

root@master:/home/data/harbor# sudo docker login 49.0.241.2 admin Harbor12345

1.报错原因分析

root@master:/home/data/harbor# docker push 49.0.241.2/library/nginx:latest #这种报错
The push refers to repository [49.0.241.2/library/nginx]
Get "https://49.0.241.2/v2/": dial tcp 49.0.241.2:443: connect: connection refused


root@master:/home/data/harbor# docker push   49.0.241.2/library/nginx:latest  #这种报错
The push refers to repository [49.0.241.2/library/nginx]
922d16116201: Preparing 
abc3beec4b30: Preparing 
c88d3a8ff009: Preparing 
8aedfcd777c7: Preparing 
4deafab383fa: Preparing 
24ee1d7d6a62: Waiting 
c6e34807c2d5: Waiting 
unauthorized: unauthorized to access repository: library/nginx, action: push: unauthorized to access repository: library/nginx, action: push

2.处理报错问题

#daemon.json中添加insecure-registries字段,代表上传不受IP限制
cat  /etc/docker/daemon.json 
{
    "insecure-registries": ["0.0.0.0/0"],
    "registry-mirrors": ["https://wbdhknhl.mirror.aliyuncs.com"]
}

root@master:/home/data/harbor#  docker login 49.0.241.2  #登录harbor
Username: admin
Password:  #密码默认是Harbor12345
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

Login Succeeded
root@master:/home/data/harbor# 

systemctl daemon-reload
systemctl restart docker

3.测试效果

root@master:/home/data/harbor# docker push   49.0.241.2/library/nginx:latest 
The push refers to repository [49.0.241.2/library/nginx]
922d16116201: Layer already exists 
abc3beec4b30: Layer already exists 
c88d3a8ff009: Layer already exists 
8aedfcd777c7: Layer already exists 
4deafab383fa: Layer already exists 
24ee1d7d6a62: Pushed 
c6e34807c2d5: Pushed 
latest: digest: sha256:73e957703f1266530db0aeac1fd6a3f87c1e59943f4c13eb340bb8521c6041d7 size: 1778
root@master:/home/data/harbor# 

在这里插入代码片

docker push 报错:unauthorized: unauthorized to access repository: library/xx处理方法_第1张图片上图可以看到上传的镜像

docker push 报错:unauthorized: unauthorized to access repository: library/xx处理方法_第2张图片上图是下载镜像成功

docker push 报错:unauthorized: unauthorized to access repository: library/xx处理方法_第3张图片上图可以看到下载一次

你可能感兴趣的:(docker容器相关,linux,docker,chrome,容器)