#首次登陆生成key.json文件
[root@localhost ~]#docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: shuzihan
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@localhost ~]#docker tag ubuntu2204:v1.0 docker.io/shuzihan/ubuntu2004:v1.0
[root@localhost ~]#docker push docker.io/shuzihan/ubuntu2004:v1.0
[root@localhost ~]#vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://si7y70hh.mirror.aliyuncs.com","https://registry.cn-hangzhou.aliyuncs.com"],
"insecure-registries": ["10.0.0.201","10.0.0.202"] //加上私仓地址
}
[root@localhost ~]#docker login 10.0.0.201
Username: admin
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@localhost ~]#docker login 10.0.0.202
Username: admin
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@localhost ~]#docker tag ubuntu2204:v1.0 10.0.0.201/public/ubuntu2204:v1.0
[root@localhost ~]#docker push 10.0.0.201/public/ubuntu2204:v1.0
The push refers to repository [10.0.0.201/public/ubuntu2204]
75004da5ffb5: Pushed
55439565899f: Pushed
950d1cd21157: Pushed
v1.0: digest: sha256:bc45c1f028eabecdc82def0c5592d19387b9865831e110820c3dddac12ccc079 size: 948
配置harbor集群双向复制(高可用还可以使用ceph分布式存储,共享存储)
#在10.0..0.201上做相同配置实现双向复制
#测试分别在201和202上传不同镜像
[root@localhost ~]#docker tag jdk8u341:v1.0 10.0.0.201/public/jdk8u341:v1.0
[root@localhost ~]#docker push 10.0.0.201/public/jdk8u341:v1.0
The push refers to repository [10.0.0.201/public/jdk8u341]
07cc6a232432: Pushed
2511ca3702e4: Pushed
c1ab25fd6049: Pushed
75004da5ffb5: Mounted from public/ubuntu2204
55439565899f: Mounted from public/ubuntu2204
950d1cd21157: Mounted from public/ubuntu2204
v1.0: digest: sha256:c73c5c30ac8111c8f1a1a7cd8e20fcf4487bc07bf8b8e8498fcb533b00c85c96 size: 1575
[root@localhost ~]#docker tag tomcat9.0.65:v1.0 10.0.0.201/public/tomcat9.0.65:v1.0
[root@localhost ~]#docker login 10.0.0.202
Authenticating with existing credentials...
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@localhost ~]#docker push 10.0.0.201/public/tomcat9.0.65:v1.0
The push refers to repository [10.0.0.201/public/tomcat9.0.65]
7df9b9b96147: Pushed
0f22a5e73f4e: Pushed
808846401514: Pushed
5afea52a49ce: Pushed
942af327c611: Pushed
be3983177bd2: Pushed
84bca088201d: Pushed
07cc6a232432: Mounted from public/jdk8u341
2511ca3702e4: Mounted from public/jdk8u341
c1ab25fd6049: Mounted from public/jdk8u341
75004da5ffb5: Mounted from public/jdk8u341
55439565899f: Mounted from public/jdk8u341
950d1cd21157: Mounted from public/jdk8u341
v1.0: digest: sha256:6b30fa57e9bf78f0883108299fee1c9c9dc8b68b117c0bd1a0d72a9bcd2571ac size: 3037