使用harbor搭建私有docker镜像仓库

9644303-d117ee06e3a390a9.png
image.png
1. 环境准备
yum -y install docker 
setenforce 0 
systemct stop firewalld 
systemctl start docker
报错 修改/etc/sysconfig/docker
selinux-enabled=false
安装:docker-compose
yum install -y epel-release
yum install -y python-pip
如有报错更新pip
python -m pip install --upgrade pip
pip install docker-compose 
docker --version 
docker-compose --version

安装Harbor 下载harbor二进制文件(不要下源码哦)
https://github.com/vmware/harbor/releases>
tar xvf harbor-offline-installer-<version>.tgz

修改harbor.cfg
只需要修改hostname为你自己的机器IP或者域名,harbor默认的db连接密码为root123,可以自己修改,也可以保持默认
harbor初始管理员密码为Harbor12345
执行安装

./install.sh
报错:
[Step 4]: starting Harbor ... Creating harbor-log ... error ERROR: for harbor-log Cannot start service log: driver failed programming external connectivity on endpoint harbor-log (6d494078cf7b3f8810bb04abfa768732e3461c1c832d004b6ccf4802aea28392): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 127.0.0.1 --dport 1514 -j DNAT --to-destination 172.18.0.2:10514 ! -i br-5405e15dcd56: iptables: No chain/target/match by that name. (exit status 1)) ERROR: for log Cannot start service log: driver failed programming external connectivity on endpoint harbor-log (6d494078cf7b3f8810bb04abfa768732e3461c1c832d004b6ccf4802aea28392): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 127.0.0.1 --dport 1514 -j DNAT --to-destination 172.18.0.2:10514 ! -i br-5405e15dcd56: iptables: No chain/target/match by that name. (exit status 1)) ERROR: Encountered errors while bringing up the project.

系统需升级内核到4.0,kernel4.0对overlay2支持

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 
yum install http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm 
yum --enablerepo=elrepo-kernel install kernel-ml 
reboot
重启harbor
docker-compose  restart
报错:
   Step 4]: starting Harbor ... Creating network "harbor_harbor" with the default driver ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-54d45cf40b6c -j RETURN: iptables: No chain/target/match by that name. 重启docker
systemctl  restart docker

访问IP地址web页面
user: admin
passwd: Harbor12345

9644303-3f1769cbfcc1583c.png
image.png

新建项目test
登陆上传镜像

 docker login 192.168.16.225 
Username: admin
Password: 
# Error response from daemon: Get https://192.168.16.225/v1/users/: dial tcp 192.168.16.225:443: getsockopt: connection refused 
#解决: 
vim /usr/lib/systemd/system/docker.service
在ExecStart=/usr/bin/dockerd后
追加  --insecure-registry=192.168.16.225 
#重启docker 
systemctl  daemon-reload
systemctl restart docker 
#新版docker更改  
[root@ harbor]# cat /etc/docker/daemon.json 
{
    "insecure-registries": [
    "192.168.16.225"
  ]
}
注意:json格式,建议复制 
重试登陆


[root@localhost ~]# docker login 192.168.16.225
Username: admin 
Password: Login Succeeded 
上传镜像 
[root@localhost ~]# docker images
 REPOSITORY           TAG  IMAGE ID      CREATED  SIZE
 docker.io/centos   latest 50dae1ee8677 2 years ago 197 MB
[root@localhost ~]# docker tag docker.io/centos 192.168.16.225/test/centos 
[root@localhost ~]# docker push 192.168.16.225/test/centos 
The push refers to a repository [192.168.16.225/test/centos] 0fe55794a0f7: 
Pushed latest: digest: sha256:a8ec3eb2a1dec886d772cccf22659649401783fff35f489ee8226fd3e11e2b6e size: 529 

去web查看是否上传成功


9644303-c06fe194289a19c2.png
image.png

猜你喜欢

转载自blog.csdn.net/weixin_34226706/article/details/87229434