Harbor仓库离线部署
harbor安装包下载地址:harbor
环境准备
系统: Centos7 1C1G
docker
docker-compose
[root@localhost ~]# docker --version
Docker version 19.03.13, build 4484c46d9d
[root@localhost ~]# docker-compose --version
docker-compose version 1.26.2, build eefe0d31
1.安装harbor
[root@localhost ~]# ls
anaconda-ks.cfg harbor-offline-installer-v1.9.4.tgz
[root@localhost ~]# tar zxf harbor-offline-installer-v1.9.4.tgz
[root@localhost ~]# mv harbor /usr/local/
[root@localhost ~]# cd /usr/local/harbor/
[root@localhost harbor]# vim harbor.yml
//修改这些
hostname: 192.168.176.137
http:
port: 80
harbor_admin_password: admin
[root@localhost harbor]# ls
harbor.v1.9.4.tar.gz harbor.yml install.sh LICENSE prepare
[root@localhost harbor]# ./install.sh
//[Step 3]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-portal ... done
Creating registry ... done
Creating redis ... done
Creating harbor-db ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating harbor-jobservice ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
[root@localhost harbor]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://q3u0qv3z.mirror.aliyuncs.com"],
"insecure-registries":["192.168.176.137"]
}
[root@localhost harbor]# systemctl daemon-reload
[root@localhost harbor]# systemctl restart docker
2.登录私有仓库
[root@localhost harbor]# docker login 192.168.176.137
Username: admin
Password:
Error response from daemon: Get http://192.168.176.137/v2/: dial tcp 192.168.176.137:80: connect: connection refused
//没有登录成功,需要重启harbor相关容器
[root@localhost harbor]# docker-compose down -v
[root@localhost harbor]# docker-compose up -d
[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)
//重新登录
[root@localhost harbor]# docker login 192.168.176.137
Username: admin
Password:
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
3.登录Harbor
//关闭防火墙
[root@localhost harbor]# systemctl stop firewalld
[root@localhost harbor]# setenforce 0
访问端口为 80
4.向harbor仓库中推送mysql镜像
[root@localhost harbor]# docker pull mysql:5.7
[root@localhost harbor]# docker tag mysql:5.7 192.168.176.137/docker/mysql:5.7
[root@localhost harbor]# docker push 192.168.176.137/docker/mysql:5.7
5.从harbor仓库中下载镜像
[root@localhost harbor]# docker pull 192.168.176.137/docker/mysql:5.7