搭建harbor 镜像平台
一 安装docker环境
CentOS7.x安装Docker # 安装依赖包 yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加Docker软件包源 yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo # 安装Docker CE yum install -y docker-ce # 启动Docker服务并设置开机启动 systemctl start docker systemctl enable docker
配置加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
安装docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
二 安装harbor
解压二进制包
tar -zxvf ./harbor-offline-installer-v1.9.1.tgz
[root@localhost ~]# ll ./harbor total 607872 -rw-r--r--. 1 root root 622428100 Sep 27 2019 harbor.v1.9.1.tar.gz -rw-r--r--. 1 root root 5805 Sep 27 2019 harbor.yml -rwxr-xr-x. 1 root root 5088 Sep 27 2019 install.sh -rw-r--r--. 1 root root 11347 Sep 27 2019 LICENSE -rwxr-xr-x. 1 root root 1748 Sep 27 2019 prepare
# tar zxvf harbor-offline-installer-v1.9.1.tgz # cd harbor # vi harbor.yml hostname: 192.168.31.70 (修改为自己的IP地址) # ./prepare # ./install.sh
完成之后查看状态
[root@localhost harbor]# docker-compose ps Name Command State Ports ------------------------------------------------------------------------------------------------------ harbor-core /harbor/harbor_core Up (health: starting) harbor-db /docker-entrypoint.sh Up (health: starting) 5432/tcp harbor-jobservice /harbor/harbor_jobservice ... Up (health: starting) harbor-log /bin/sh -c /usr/local/bin/ ... Up (health: starting) 127.0.0.1:1514->10514/tcp harbor-portal nginx -g daemon off; Up (health: starting) 8080/tcp nginx nginx -g daemon off; Up (health: starting) 0.0.0.0:80->8080/tcp redis redis-server /etc/redis.conf Up (health: starting) 6379/tcp registry /entrypoint.sh /etc/regist ... Up (health: starting) 5000/tcp registryctl /harbor/start.sh Up (health: starting)
登录harbor 端口为80
密码在配置文件中
harbor_admin_password: Harbor12345
三 将本地的镜像上传到harbol仓库
docker tag nginx:latest 192.168.80.134/library/nginx:v3
[root@localhost harbor]# docker pull 192.168.80.134/library/nginx:v3
Error response from daemon: Get https://192.168.80.134/v2/: dial tcp 192.168.80.134:443: connect: connection refused
发现报错。
报错原因,docker默认连接的是https harbol 没有启用https
解决办法
修改文件
vim /etc/docker/daemon.json 添加
"insecure-registries" :["192.168.80.134"]
重启docker
systemctl restart docker
再次push
docker push 192.168.80.134/library/nginx:v3
抛错
denied: requested access to the resource is denied
是因为没有登录
docker login 192.168.80.134 输入账号密码 再次push成功