【docker】将镜像文件上传到Harbor

1.获取nginx的镜像 

[root@es1 harbor]# docker pull nginx:latest
latest: Pulling from library/nginx
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Image is up to date for nginx:latest

docker.io/library/nginx:latest
[root@es1 harbor]# docker pull busybox:1.28.3
1.28.3: Pulling from library/busybox
Digest: sha256:58ac43b2cc92c687a32c8be6278e50a063579655fe3090125dcb2af0ff9e1a64
Status: Image is up to date for busybox:1.28.3
docker.io/library/busybox:1.28.3

2.给镜像打标签

/myharbor/:是我创建的harbor工程的名称。
docker tag nginx:latest 192.168.1.11:443/myharbor/nginx:latest   
docker tag busybox:1.28.3 192.168.1.11:443/myharbor/busybox:1.28.3

[root@es1 harbor]# docker tag nginx:latest 192.168.1.11:443/myharbor/nginx:latest 
[root@es1 harbor]# docker tag busybox:1.28.3 192.168.1.11:443/myharbor/busybox:1.28.3
[root@es1 harbor]# 
[root@es1 harbor]# 
[root@es1 docker]# docker image ls
REPOSITORY                          TAG       IMAGE ID       CREATED       SIZE
192.168.1.11:443/myharbor/nginx     latest    605c77e624dd   2 years ago   141MB
nginx                               latest    605c77e624dd   2 years ago   141MB
my_mysql                            latest    3218b38490ce   2 years ago   516MB
mysql                               latest    3218b38490ce   2 years ago   516MB
busybox                             1.28.3    8ac48589692a   6 years ago   1.15MB
192.168.1.11:443/myharbor/busybox   1.28.3    8ac48589692a   6 years ago   1.15MB

3.在docker的主节点上远程登陆harbor;

[root@es1 docker]# systemctl daemon-reload
[root@es1 docker]# systemctl restart docker
[root@es1 docker]# docker login 192.168.1.11:443
Username: xueshuangqi	  
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

Login Succeeded

--删除错误的标签。
[root@es1 docker]# docker rmi 192.168.1.11:8880/xueshuangqi/busybox:1.28.3
Untagged: 192.168.1.11:8880/xueshuangqi/busybox:1.28.3

4.将镜像推送到Harbor;

--检查现有镜像。
[root@es1 docker]# docker image ls
REPOSITORY                          TAG       IMAGE ID       CREATED       SIZE
192.168.1.11:443/myharbor/nginx     latest    605c77e624dd   2 years ago   141MB
nginx                               latest    605c77e624dd   2 years ago   141MB
my_mysql                            latest    3218b38490ce   2 years ago   516MB
mysql                               latest    3218b38490ce   2 years ago   516MB
busybox                             1.28.3    8ac48589692a   6 years ago   1.15MB
192.168.1.11:443/myharbor/busybox   1.28.3    8ac48589692a   6 years ago   1.15MB

--我使用的是xueshuangqi 用户,该用户不是管理员。无法上传。
docker push 192.168.1.11:443/myharbor/nginx:latest 
[root@es1 docker]# docker push 192.168.1.11:443/myharbor/nginx
Using default tag: latest
The push refers to repository [192.168.1.11:443/myharbor/nginx]
d874fd2bc83b: Preparing 
32ce5f6a5106: Preparing 
f1db227348d0: Preparing 
b8d6e692a25e: Preparing 
e379e8aedd4d: Preparing 
2edcec3590a4: Preparing 
denied: requested access to the resource is denied

--添加管理员权限重新尝试。
[root@es1 docker]# docker push 192.168.1.11:443/myharbor/nginx:latest
The push refers to repository [192.168.1.11:443/myharbor/nginx]
d874fd2bc83b: Pushed 
32ce5f6a5106: Pushed 
f1db227348d0: Pushed 
b8d6e692a25e: Pushed 
e379e8aedd4d: Pushed 
2edcec3590a4: Pushed 
latest: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570


docker push 192.168.1.11:443/myharbor/busybox:1.28.3
[root@es1 docker]# docker push 192.168.1.11:443/myharbor/busybox:1.28.3
The push refers to repository [192.168.1.11:443/myharbor/busybox]
0314be9edf00: Pushed 
1.28.3: digest: sha256:186694df7e479d2b8bf075d9e1b1d7a884c6de60470006d572350573bfa6dcd2 size: 527

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值