2.1 harbor仓库安装、配置、TAG、上传、
一)上传安装包到安装目录“harbor-offline-installer-v1.6.1.tgz”和“docker-compose”
[root@itpux bin]# cd /mysql/app/ [root@itpux app]# ll 总用量 677332 -rw-r--r--. 1 root root 8858808 10月 26 09:07 docker-compose drwxr-xr-x. 4 root root 4096 10月 26 11:33 harbor -rw-r--r--. 1 root root 26544422 10月 26 09:07 harbor-1.6.1.tar.gz -rw-r--r--. 1 root root 658170229 10月 26 09:06 harbor-offline-installer-v1.6.1.tgz [root@itpux app]# pwd /mysql/app [root@itpux app]#
二)修改daemon.json的配置文件
[root@itpux docker]# pwd /etc/docker [root@itpux docker]# vim daemon.json [root@itpux docker]# cat daemon.json { "insecure-registries":["192.168.26.188","192.168.205.150","10.124.133.178","10.236.4.81","10.124.133.191","10.162.145.32:80","192.168.205.150 :8081","https://w42fkznc.mirror.aliyuncs.com"] } [root@itpux docker]#
三)将容器编排文件赋权和移动到指定目录
[root@itpux app]# chmod 777 docker-compose [root@itpux app]# ll 总用量 677332 -rwxrwxrwx. 1 root root 8858808 10月 26 09:07 docker-compose drwxr-xr-x. 4 root root 4096 10月 26 11:38 harbor -rw-r--r--. 1 root root 26544422 10月 26 09:07 harbor-1.6.1.tar.gz -rw-r--r--. 1 root root 658170229 10月 26 09:06 harbor-offline-installer-v1.6.1.tgz [root@itpux app]# mv docker-compose /usr/local/bin/ [root@itpux app]#
四)修改配置参数表
[root@itpux app]# cd harbor/ [root@itpux harbor]# ll 总用量 650116 drwxr-xr-x. 3 root root 4096 10月 26 11:29 common -rw-r--r--. 1 root root 727 10月 16 11:52 docker-compose.chartmuseum.yml -rw-r--r--. 1 root root 777 10月 16 11:52 docker-compose.clair.yml -rw-r--r--. 1 root root 1258 10月 16 11:52 docker-compose.notary.yml -rw-r--r--. 1 root root 3589 10月 16 11:52 docker-compose.yml drwxr-xr-x. 3 root root 4096 10月 16 11:52 ha -rw-r--r--. 1 root root 7913 10月 16 11:52 harbor.cfg -rw-r--r--. 1 root root 664077077 10月 16 11:53 harbor.v1.6.1.tar.gz -rwxr-xr-x. 1 root root 6162 10月 16 11:52 install.sh -rw-r--r--. 1 root root 10768 10月 16 11:52 LICENSE -rw-r--r--. 1 root root 482 10月 16 11:52 NOTICE -rw-r--r--. 1 root root 1535603 10月 16 11:52 open_source_license -rwxr-xr-x. 1 root root 39496 10月 16 11:52 prepare [root@itpux harbor]# vim harbor.cfg
将cfg文件修改host地址为本机

五)安装
[root@itpux harbor]# ./install.sh [Step 0]: checking installation environment ... Note: docker version: 1.12.6 Note: docker-compose version: 1.18.0 [Step 1]: loading Harbor images ... ad50e89f4922: Loading layer [==================================================>] 133.4 MB/133.4 MB 8c9a00a7f290: Loading layer [==================================================>] 73.29 MB/73.29 MB 078e22641f73: Loading layer [==================================================>] 3.584 kB/3.584 kB 5494f0d704cb: Loading layer [==================================================>] 3.072 kB/3.072 kB 34c7e304d18b: Loading layer [==================================================>] 4.096 kB/4.096 kB ae9209f78c11: Loading layer [==================================================>] 3.584 kB/3.584 kB 1498359f7391: Loading layer [==================================================>] 9.728 kB/9.728 kB
六、检查启动的容器
[root@itpux harbor]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1ca63a08b779 goharbor/nginx-photon:v1.6.1 "nginx -g 'daemon off" 3 minutes ago Up 3 minutes (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx 6b83334175e4 goharbor/harbor-jobservice:v1.6.1 "/harbor/start.sh" 3 minutes ago Up 3 minutes harbor-jobservice 4f754e7c7ea4 goharbor/harbor-ui:v1.6.1 "/harbor/start.sh" 3 minutes ago Up 3 minutes (healthy) harbor-ui 755c6a3262f3 goharbor/registry-photon:v2.6.2-v1.6.1 "/entrypoint.sh /etc/" 3 minutes ago Up 3 minutes (healthy) 5000/tcp registry e026588bcea5 goharbor/harbor-db:v1.6.1 "/entrypoint.sh postg" 3 minutes ago Up 3 minutes (healthy) 5432/tcp harbor-db b543249a3e71 goharbor/harbor-adminserver:v1.6.1 "/harbor/start.sh" 3 minutes ago Up 2 minutes (healthy) harbor-adminserver 657702a5dfef goharbor/redis-photon:v1.6.1 "docker-entrypoint.sh" 3 minutes ago Up 3 minutes 6379/tcp redis 515427da049e goharbor/harbor-log:v1.6.1 "/bin/sh -c /usr/loca" 3 minutes ago Up 3 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log [root@itpux harbor]#
七、异常处理:仓库容器已经启动,但无法打开默认仓库网页;问题2:web页帐号能登陆,命令无法进入。
一)问题1:仓库容器已经启动,但无法打开默认仓库网页;
1、仓库容器已经启动,但无法打开默认仓库网页
[root@itpux harbor]# systemctl stop docker
[root@itpux harbor]# systemctl start docker
[root@itpux harbor]#
2、重新加载仓库
[root@itpux harbor]# ./install.sh [Step 0]: checking installation environment ... Note: docker version: 1.12.6 Note: docker-compose version: 1.18.0 [Step 1]: loading Harbor images ... Loaded image: goharbor/harbor-log:v1.6.1 Loaded image: goharbor/harbor-jobservice:v1.6.1 Loaded image: goharbor/redis-photon:v1.6.1 Loaded image: goharbor/nginx-photon:v1.6.1 Loaded image: goharbor/harbor-migrator:v1.6.1 Loaded image: goharbor/chartmuseum-photon:v0.7.1-v1.6.1 Loaded image: goharbor/harbor-ui:v1.6.1 Loaded image: goharbor/harbor-db:v1.6.1 Loaded image: goharbor/registry-photon:v2.6.2-v1.6.1 Loaded image: goharbor/notary-server-photon:v0.5.1-v1.6.1 Loaded image: goharbor/notary-signer-photon:v0.5.1-v1.6.1 Loaded image: goharbor/clair-photon:v2.0.6-v1.6.1 Loaded image: goharbor/harbor-adminserver:v1.6.1
二)问题2:web页帐号能登陆,命令无法进入。
因为配置文件中未增加母机IP地址,增加后需要重启DOCKER。
[root@itpux docker]# pwd
/etc/docker
[root@itpux docker]# vim daemon.json
[root@itpux docker]# cat daemon.json
{ "insecure-registries":["192.168.26.188","192.168.205.150","10.124.133.178","10.236.4.81","10.124.133.191","10.162.145.32:80","192.168.205.150 :8081","https://w42fkznc.mirror.aliyuncs.com"] }
[root@itpux docker]#
[root@itpux docker]# systemctl stop docker
[root@itpux docker]# systemctl start docker
八、登陆仓库
[root@itpux harbor]# docker login http://192.168.26.188 Username: admin Password: Login Succeeded [root@itpux harbor]#
九、TAG标签,必须与仓库IP地址和文件夹library一致,或者提交创建文件夹名称。
docker tag caf1cb01c233 192.168.26.188/library/contos/tomcat8:v1
镜像IMAGE ID(caf1cb01c233 ) 仓库IP地址(192.168.26.188) 仓库项目名称(library) 镜像名称(contos/tomcat8:) 版本号(v1)
[root@itpux harbor]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE <none> <none> caf1cb01c233 11 hours ago 415.2 MB contos/tomcat8 v1 20fdf1c54490 11 hours ago 595.8 MB contos/mysql5.7 v1 0d8579c7da5f 11 hours ago 488.7 MB boonya/tomcat-web latest 48509e67ce6e 13 hours ago 595.7 MB <none> <none> 29e96687db4a 14 hours ago 300.1 MB nginxdocker/nginxdocker v1 4700aa51860f 17 hours ago 415.2 MB mysql latest 2dd01afbe8df 30 hours ago 485.5 MB goharbor/chartmuseum-photon v0.7.1-v1.6.1 f0a2dbee1ff1 10 days ago 350.4 MB goharbor/harbor-migrator v1.6.1 60e8be845b35 10 days ago 797.6 MB goharbor/redis-photon v1.6.1 6a67380bb061 10 days ago 209.6 MB goharbor/clair-photon v2.0.6-v1.6.1 c4fcdbae7df2 10 days ago 302.2 MB goharbor/notary-server-photon v0.5.1-v1.6.1 f1afd44d9f9b 10 days ago 208.9 MB goharbor/notary-signer-photon v0.5.1-v1.6.1 83aa51867207 10 days ago 206.5 MB goharbor/registry-photon v2.6.2-v1.6.1 f4cb5e83f0a4 10 days ago 195.6 MB goharbor/nginx-photon v1.6.1 9ca888fe33b2 10 days ago 132.4 MB goharbor/harbor-log v1.6.1 9b1ea3f29465 10 days ago 197.5 MB goharbor/harbor-jobservice v1.6.1 9ca6fd371ca6 10 days ago 192.3 MB goharbor/harbor-ui v1.6.1 305ee5b8952c 10 days ago 215 MB goharbor/harbor-adminserver v1.6.1 a3e95f74984e 10 days ago 181.2 MB goharbor/harbor-db v1.6.1 3bea3bff0190 10 days ago 219.4 MB centos/mysql-57-centos7 latest b996585055be 2 weeks ago 448.1 MB centos latest 75835a67d134 2 weeks ago 200.4 MB [root@itpux harbor]# docker tag caf1cb01c233 192.168.26.188/library/contos/tomcat8:v1
十、PULL 镜像至仓库
[root@itpux harbor]# docker push 192.168.26.188/library/contos/tomcat8:v1 The push refers to a repository [192.168.26.188/library/contos/tomcat8] An image does not exist locally with the tag: 192.168.26.188/library/contos/tomcat8 [root@itpux harbor]# docker push 192.168.26.188/library/contos/tomcat8:v1 The push refers to a repository [192.168.26.188/library/contos/tomcat8] An image does not exist locally with the tag: 192.168.26.188/library/contos/tomcat8 [root@itpux harbor]# docker tag ^C [root@itpux harbor]# docker tag caf1cb01c233 192.168.26.188/library/contos/tomcat8:v1 [root@itpux harbor]# docker push 192.168.26.188/library/contos/tomcat8:v1 The push refers to a repository [192.168.26.188/library/contos/tomcat8] 23fc22e9bc67: Pushed c5cf4f5198ec: Pushed f972d139738d: Pushed v1: digest: sha256:cc9e37a9ab61d645fa1c44afb8d4f591e419ea98d36dd6f9ac8e40199e0fb37a size: 949 [root@itpux harbor]#
十一、登陆仓库进行查看

十二、修改开机启动仓库,并启动mysql容器和nginx容器
[root@itpux lib]# vi /etc/rc.local
[root@itpux lib]#
#!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot. touch /var/lock/subsys/local echo '512' > /sys/block/sdb/queue/nr_requests echo '512' > /sys/block/sdc/queue/nr_requests sleep 15 /mysql/app/harbor/install.sh sleep 50 docker start nginxserver sleep 15 docker start mymysql
浙公网安备 33010602011771号