1.200机器安装harbor仓库

  1. [root@hdss7-200 ~]# mkdir -p /opt/src
  2. [root@hdss7-200 ~]# cd /opt/src
  3. [root@hdss7-200 src]# ll
  4. total 566428
  5. -rw-r--r-- 1 root root 580021898 Apr 1 18:46 harbor-offline-installer-v1.8.3.tgz
  6. [root@hdss7-200 src]# tar xf harbor-offline-installer-v1.8.3.tgz -C /opt/
  7. # 把软件包做版本标识,做一个软链接,便于以后升级
  8. [root@hdss7-200 src]# cd ..
  9. [root@hdss7-200 opt]# mv harbor/ harbor-v1.8.0
  10. [root@hdss7-200 opt]# ln -s /opt/harbor-v1.8.0/ /opt/harbor
  11. [root@hdss7-200 opt]# ll
  12. total 0
  13. drwxr-xr-x 2 root root 71 Jun 6 11:19 certs
  14. drwx--x--x 4 root root 28 Jun 6 11:43 containerd
  15. lrwxrwxrwx 1 root root 19 Jun 6 11:57 harbor -> /opt/harbor-v1.8.0/
  16. drwxr-xr-x 2 root root 100 Jun 6 11:57 harbor-v1.8.0
  17. drwxr-xr-x 2 root root 49 Jun 6 11:55 src
  18. 编辑harbor文件
  19. [root@hdss7-200 opt]# cd harbor
  20. [root@hdss7-200 harbor]# vi harbor.yml
  21. 5 hostname: harbor.od.com
  22. 10 port: 180
  23. 27 harbor_admin_password: Harbor12345
  24. 40 data_volume: /data/harbor
  25. 87 location: /data/harbor/logs # 更改日志存储路径
  26. [root@hdss7-200 harbor]# mkdir -p /data/harbor/logs
  27. 单机编排工具
  28. [root@hdss7-200 harbor]# yum install -y docker-compose
  29. [root@hdss7-200 harbor]# rpm -qa docker-compose
  30. docker-compose-1.18.0-4.el7.noarch
  31. 安装
  32. [root@hdss7-200 harbor]# ./install.sh
  33. [root@hdss7-200 harbor]# docker-compose ps
  34. 每次重启docker需要执行也可以通过脚本方式启动
  35. [root@hdss7-200 harbor]# docker-compose up -d

image.png

2.安装nginx做反向代理

  1. [root@hdss7-200 harbor]# yum install -y nginx
  2. [root@hdss7-200 harbor]# vi /etc/nginx/conf.d/harbor.od.com.conf
  3. server {
  4. listen 80;
  5. server_name harbor.od.com;
  6. client_max_body_size 1000m;
  7. location / {
  8. proxy_pass http://127.0.0.1:180;
  9. }
  10. }
  11. [root@hdss7-200 harbor]# nginx -t
  12. [root@hdss7-200 harbor]# systemctl start nginx
  13. [root@hdss7-200 harbor]# systemctl enable nginx

3 dns服务器配置域名

[root@hdss7-11 ~]# vi /var/named/od.com.zone 
[root@hdss7-11 ~]# cat /var/named/od.com.zone
$ORIGIN od.com.
$TTL 600    ; 10 minutes
@           IN SOA    dns.od.com. dnsadmin.od.com. (
                20200606 ; serial
                10800      ; refresh (3 hours)
                900        ; retry (15 minutes)
                604800     ; expire (1 week)
                86400      ; minimum (1 day)
                )
                NS   dns.od.com.
$TTL 60    ; 1 minute
dns                A    192.168.12.11
harbor             A    192.168.12.200
[root@hdss7-11 ~]# systemctl restart named
[root@hdss7-11 ~]# dig -t A harbor.od.com +short
192.168.12.200

image.png
新建一个public项目,公开
[root@hdss7-200 harbor]# docker pull nginx:1.7.9
[root@hdss7-200 harbor]# docker tag nginx:1.7.9 harbor.od.com/public/nginx:v1.7.9
[root@hdss7-200 harbor]# docker login harbor.od.com
[root@hdss7-200 harbor]# docker push harbor.od.com/public/nginx:v1.7.9