安装 Docker、Docker-Compose
https://www.cnblogs.com/jhxxb/p/11410816.html
修改上传配置
vim /etc/docker/daemon.json { "insecure-registries" : ["http://myregistrydomain.com:5000", "0.0.0.0"] } # 重启服务 systemctl restart docker
安装 Harbor
下载 Harbor(harbor-offline-installer):https://github.com/goharbor/harbor/releases
# 解压 tar -zxf harbor-offline-installer-v2.0.2.tgz # 进入解压的目录,修改配置 cp harbor.yml.tmpl harbor.yml vim harbor.yml
修改配置(测试使用,不配置证书)
# 修改地址 hostname: 192.168.8.138 # 注释掉 https 访问 # https related config #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
安装启动
./install.sh
默认为 80 端口,用户名:admin,密码:Harbor12345
停止、重启 Harbor(需要在安装目录下运行)
# Stop Harbor. docker-compose down -v # Restart Harbor docker-compose up -d
开机自启
vim /lib/systemd/system/harbor.service [Unit] Description=Harbor After=docker.service systemd-networkd.service systemd-resolved.service Requires=docker.service Documentation=http://github.com/goharbor/harbor [Service] Type=simple Restart=on-failure RestartSec=5 ExecStart=/usr/bin/docker-compose -f /opt/harbor/docker-compose.yml up ExecStop=/usr/bin/docker-compose -f /opt/harbor/docker-compose.yml down [Install] WantedBy=multi-user.target systemctl enable harbor systemctl start harbor
上传镜像
若上传失败请检查 /etc/docker/daemon.json 是否配置正确
# 需要配置 insecure-registries vim /etc/docker/daemon.json { "registry-mirrors": ["https://ke9h1pt4.mirror.aliyuncs.com"], "insecure-registries": ["http://xxx.xxx.xxx.xxx"] }
上传
docker tag cd645f5a4769 192.168.8.138/library/mysql:latest # admin Harbor12345 docker login 192.168.8.138 # 上传 docker push 192.168.8.138/library/mysql:latest
批量执行
# 批量 tag for i in $(docker images | grep ^pig | awk 'BEGIN{OFS=":"}{print $1,$2}'); do docker tag $i xxx.xxx.xxx.xxx/xx-name/$i; done # 批量 push for i in $(docker images | grep xx-name | awk 'BEGIN{OFS=":"}{print $1,$2}'); do docker push $i; done