离线手动部署docker镜像仓库——harbor仓库(二)

前言:

在《离线手动部署docker镜像仓库——harbor仓库(一)》中,记录了离线部署harbor仓库的简单过程,这里主要记录修改默认访问端口80端口为1180端口的部署方式和注意点。

实验环境:
harbor服务器系统:CentOS Linux release 7.4.1708 (Core)
harbor服务器IP:10.0.0.101
harbor版本:v1.5.0
docker版本:1.13.1
另外为了测试pull镜像,使用了另一台test102机器:10.0.0.102

部署过程:

1、下载安装包

下载地址:http://harbor.orientsoft.cn/

2、上传并解压安装包

将下载下来的安装包上传到服务器的/home目录,并解压。

[root@test101 home]# tar xf harbor-offline-installer-v1.5.0.tgz 
[root@test101 home]# ll
总用量 843504
drwxr-xr-x. 4 root root       229 7月  30 15:48 harbor
-rw-r--r--. 1 root root 863747205 7月  30 15:39 harbor-offline-installer-v1.5.0.tgz
[root@test101 home]# 

3、配置harbor和docker修改配置(重点)

3.1 编辑/home/habor/harbor.cfg,主要修改两个地方:

hostname = 10.0.0.101   #这里直接用的IP
harbor_admin_password = 123456   #登录harbor仓库的密码,默认密码是Harbor12345

3.2 修改默认的80端口,需要修改两个文件:

1)修改/home/harbor/docker-compose.yml,将ports模块里面138行默认的80端口改成1180:
离线手动部署docker镜像仓库——harbor仓库(二)

2)修改/home/harbor/common/templates/registry/config.yml,在auth模块,第23行加入1180端口:
离线手动部署docker镜像仓库——harbor仓库(二)

3)修改/etc/sysconfig/docker,让docker指向10.0.0.101:1180(这里千万记得加上1180端口):
离线手动部署docker镜像仓库——harbor仓库(二)

3.3 重启docker服务:

[root@test101 ~]# systemctl daemon-reload    #踩过的坑证明,这一步最好不要忘了,不然即使重启了docker,配置文件有可能也会不生效,导致各种奇怪的问题
[root@test101 ~]# systemctl restart docker

4、安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

5、 执行install.sh脚本,安装harbor仓库

[root@test101 harbor]# ./install.sh 

离线安装docker-compose和执行install.sh的注意事项都在《离线手动部署docker镜像仓库——harbor仓库(一)》里面说过,就不赘述了。

6、检查部署是否OK

6.1 检查容器启动状况,已经全部OK,1180端口也OK:

离线手动部署docker镜像仓库——harbor仓库(二)

6.2 界面访问(加上1180端口哦):

离线手动部署docker镜像仓库——harbor仓库(二)

7、测试使用

7.1 登录后创建一个test项目:

离线手动部署docker镜像仓库——harbor仓库(二)

扫描二维码关注公众号,回复: 2501895 查看本文章

7.2 创建测试镜像并推送到仓库(这里也要带上端口号哟):

docker build -t 10.0.0.101:1180/test/bigdatacenter:latest /usr/local/src/bigdatacenter/
docker push 10.0.0.101:1180/test/bigdatacenter:latest

7.3 查看仓库,镜像已经存在

离线手动部署docker镜像仓库——harbor仓库(二)

7.4 复制pull命令,在test102机器上测试pull命令:

离线手动部署docker镜像仓库——harbor仓库(二)

=============下面的操作在test102机器上进行=============

1、修改docker配置文件,指向10.0.0.101:1180:
离线手动部署docker镜像仓库——harbor仓库(二)

2、重启test102的docker服务:

[root@test102 ~]# systemctl daemon-reload  #这一步千万不能省
[root@test102 ~]# systemctl restart docker

3、在test102机器上测试pull镜像:

[root@test102 ~]# docker images    #test102机器还没有任何的镜像文件
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[root@test102 ~]# 
[root@test102 ~]# docker pull 10.0.0.101:1180/test/bigdatacenter:latest  #测试pull镜像,切记带上1180端口号哟!!
Trying to pull repository 10.0.0.101:1180/test/bigdatacenter ... 
latest: Pulling from 10.0.0.101:1180/test/bigdatacenter
53478ce18e19: Pull complete 
d1c225ed7c34: Pull complete 
c6724ba0c09a: Pull complete 
de3b8705ee9f: Pull complete 
c091a284f068: Pull complete 
010503dbdd2d: Pull complete 
Digest: sha256:ce823873379c519a583756783923dd160473a60fcf78dfd869e8b33f5198f237
Status: Downloaded newer image for 10.0.0.101:1180/test/bigdatacenter:latest 
[root@test102 ~]#
[root@test102 ~]# docker images   #镜像文件拉取成功
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
10.0.0.101:1180/test/bigdatacenter   latest              6494ec224e74        About an hour ago   181 MB
[root@test102 ~]# 

注意:
注意:
注意:

这里有个问题,就是在harbor仓库复制pull命令的时候,是没有1180端口号的,命令是这样的:

docker pull 10.0.0.101/test/bigdatacenter:latest

但是因为我们把默认的80端口改成了1180端口,使用复制下来的docker pull 10.0.0.101/test/bigdatacenter:latest命令去pull镜像,就会失败的,必须带上端口号!!!
不带端口号,会报这个错:

[root@test102 ~]# docker pull 10.0.0.101/test/bigdatacenter:latest
Trying to pull repository 10.0.0.101/test/bigdatacenter ... 
Pulling repository 10.0.0.101/test/bigdatacenter
Error while pulling image: Get http://10.0.0.101/v1/repositories/test/bigdatacenter/images: dial tcp 10.0.0.101:80: getsockopt: connection refused
[root@test102 ~]# 

至此,修改端口号的harbor仓库就部署好了。

猜你喜欢

转载自blog.51cto.com/10950710/2153086