安装 Docker
请参照:
Linux CentOS7 中 Docker 的安装与升级(在线安装 + 离线安装)
下载 docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
给 docker-compose 添加执行权限
chmod +x /usr/local/bin/docker-compose
测试一下 docker-compose 是否安装成功
docker-compose --version
下载 harbor 安装文件
yum -y install wget
cd /opt
wget https://github.com/goharbor/harbor/releases/download/v2.2.3/harbor-offline-installer-v2.2.3.tgz
解压 harbor
tar -zxvf harbor-offline-installer-v2.2.3.tgz
创建配置文件
cd /opt/harbor
cp harbor.yml.tmpl harbor.yml
vi /opt/harbor/harbor.yml
## 修改为自己的IP地址或者域名
hostname: 192.168.89.128
## 修改HTTP的访问端口
http:
port: 9999
## 删除下面的https配置
# https related config
## 修改登录Harbor的web端密码(用于管理界面的登录)
harbor_admin_password: 123456
执行安装命令
./install.sh
访问 Harbor
访问地址:http://192.168.89.128:9999/
用户名:admin
密码:123456
将Docker镜像上传到Harbor
给镜像打标签
# 查看镜像
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos-jdk 8u41 12df886253b0 58 minutes ago 608MB
# 给镜像打标签
docker tag centos-jdk:8u41 192.168.89.128:9999/test/centos-jdk:8u41
# 查看我们新打的标签
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.89.128:9999/test/centos-jdk 8u41 12df886253b0 58 minutes ago 608MB
centos-jdk 8u41 12df886253b0 58 minutes a
# 推送镜像
docker push 192.168.89.128:9999/test/centos-jdk:8u41
The push refers to repository [192.168.89.128:9999/test/centos-jdk]
Get https://192.168.89.128:9999/v2/: http: server gave HTTP response to HTTPS client
重启Harbor服务
#进入harbor安装目录
cd /opt/harbor
#停止harbor
docker-compose down
#加载配置文件
./prepare
#启动harbor
docker-compose up -d
异常解决
docker push 192.168.89.128:9999/test/centos-jdk:8u41
The push refers to repository [192.168.89.128:9999/test/centos-jdk]
Get https://192.168.89.128:9999/v2/: http: server gave HTTP response to HTTPS client
异常信息:Get https://192.168.89.128:9999/v2/: http: server gave HTTP
response to HTTPS client 解决方法: 把Harbor地址加入到Docker信任列表 vi
/etc/docker/daemon.json 增加下面的内容 “insecure-registries” :
[“192.168.89.128:9999”]
docker push 192.168.89.128:9999/test/centos-jdk:8u4`在这里插入代码片`1
The push refers to repository [192.168.89.128:9999/test/centos-jdk]
unauthorized: unauthorized to access repository: test/centos-jdk, action: push: unauthorized to access repository: test/centos-jdk, action: push
异常信息:unauthorized: unauthorized to access repository: 解决方法: 执行登录操作,登录
harbor [root@localhost harbor]# docker login -u test -p Test123456
192.168.0.130:9999 Login Succeeded
docker push 192.168.89.128:9999/test/centos-jdk:8u41
The push refers to repository [192.168.89.128:9999/test/centos-jdk]
07d19369a67c: Pushed
8u41: digest: sha256:7b46c2059be28f98e2cab6ad5b8f327f3da91e144bece33d9c91e883c4dbcf70 size: 1578