搭建harbor私有仓库
-
安装docker-compose
-
下载harbor offline 线下包 https://github.com/goharbor/harbor/releases
-
解压缩harbor相关包 tar -zxvf harbor-offline-installer-v2.5.2.tgz
-
修改harbor配置文件
# Configuration file of Harbor #设置为自己主机的host那么 hostname: 192.168.209.100 # http related config http: # port for http, default is 80. If https enabled, this port will redirect to https port # 默认是80建议修改 port: 5000 # https related config 如果没有使用https 注释这段 #https: # # https port for harbor, default is 443 # port: 443 # The path of cert and key files for nginx # certificate: /your/certificate/path # private_key: /your/private/key/path # harbor web页面admin的登陆密码 harbor_admin_password: 123456 # Harbor DB configuration database: # The password for the root user of Harbor DB. Change this before any production use. password: root123 # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. max_idle_conns: 100 # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. # Note: the default number of connections is 1024 for postgres of harbor. max_open_conns: 900 # harbor数据存放目录 data_volume: /usr/local/harbor/data
-
如果不使用https加密证书修改docker的/etc/docker/daemon.json配置文件添加insecure-registries
{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],"insecure-registries": ["192.168.209.100:5000"]}
-
重启docker systemctl restart docker
-
安装harbor ./install.sh
-
访问web页面 192.168.209.100:500 使用 admin/123456进行登陆
-
添加用户 并设置为管理员
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-L2h3lunE-1657251335252)(https://gitee.com/jianimaoju/image-storage-service/raw/master/image/202207/06/153116-141420.png)]
-
创建项目
- 项目中添加用户
-
docker login + docker tag + docker push
[root@node1 harbor]# docker login 192.168.209.100:5000 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 # docker tag SOURCE_IMAGE[:TAG] 192.168.209.100:5000/test/REPOSITORY[:TAG] docker tag nginx 192.168.209.100:500/test/mynginx:v1 # docker push 192.168.209.100:5000/test/REPOSITORY[:TAG] docker push 192.168.209.100:500/test/mynginx:v1
-
其他服务器登陆harbor 拉取镜像
docker login docker pull 192.168.209.100:500/test/mynginx:v1