客户端机器访问服务端Harbor

书接上回:Docker私有仓库Harbor-CSDN博客

修改客户端机器名称

[root@host01 ~]# hostnamectl  hostname client
[root@host01 ~]# bash
[root@client ~]# 

安装docker

[root@client ~]# yum -y install  yum-utils.noarch                            
[root@client ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

添加仓库自:http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@client ~]# yum -y install  docker-ce*

镜像加速

[root@client ~]# sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://7f40piyw.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
{
  "registry-mirrors": ["https://7f40piyw.mirror.aliyuncs.com"]
}
[root@client ~]# 

 修改docker配置文件将harbor服务端的地址加入进去

 [root@client ~]# vim /usr/lib/systemd/system/docker.service 
 13 ExecStart=/usr/bin/dockerd --insecure-registry 192.168.200.133 //修改为服务端Harbor ip
 14 ExecReload=/bin/kill -s HUP $MAINPID
 15 TimeoutStartSec=0
 16 RestartSec=2
 17 Restart=always

重启docker

[root@client ~]# systemctl daemon-reload
[root@client ~]# systemctl  restart  docker.service 

登录Harbor

[root@client ~]# docker login  -u admin -p Harbor12345 http://192.168.200.133
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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@client ~]# 

下载镜像测试

[root@client ~]# docker pull cirros
Using default tag: latest
latest: Pulling from library/cirros
d0b405be7a32: Pull complete 
bd054094a037: Pull complete 
c6a00de1ec8a: Pull complete 
Digest: sha256:1e695eb2772a2b511ccab70091962d1efb9501fdca804eb1d52d21c0933e7f47
Status: Downloaded newer image for cirros:latest
docker.io/library/cirros:latest
[root@client ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
cirros       latest    f9cae1daf5f6   3 years ago   12.6MB
[root@client ~]# 

将镜像打上V2标签,随后上传到Harbor服务器上

[root@client ~]# docker tag cirros:latest 192.168.200.133/my123/cirros:v2
[root@client ~]# docker images
REPOSITORY                     TAG       IMAGE ID       CREATED       SIZE
192.168.200.133/my123/cirros   v2        f9cae1daf5f6   3 years ago   12.6MB
cirros                         latest    f9cae1daf5f6   3 years ago   12.6MB
[root@client ~]# 
[root@client ~]# docker push  192.168.200.133/my123/cirros:v2
The push refers to repository [192.168.200.133/my123/cirros]
984ad441ec3d: Layer already exists 
f0a496d92efa: Layer already exists 
e52d19c3bee2: Layer already exists 
v2: digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22 size: 943
[root@client ~]# 

 上传完成后回到Harbor服务器上查看是否存在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值