Docker build enterprise-class private warehouse mirror Harbor

First, the software environment

The host operating system: CentOS Linux release 7.7

Virtual Machine Tool: VMware® Workstation 10

Application container Engine: Docker version 19.03.7

Mirror warehouse open source software: harbor-offline-installer-v1.5.0.tgz

Command-line tool: docker-compose 1.25.4

Second, the real task

Harbor is VMware's enterprise-class open source project Docker Registry, by mirroring Harbor build enterprise-class warehouse.

Third, actual steps

1. Download the installation package offline

# Installation has online and offline are two ways to install, this installation off-line mode, can be downloaded from the official website, but the speed is very slow.

http://harbor.orientsoft.cn/

http://harbor.orientsoft.cn/harbor-v1.5.0/harbor-offline-installer-v1.5.0.tgz

2. Install Docker

Installation process

3. Installation docker-compose

#-Line installation

[root@docker /]# sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o 

/usr/local/bin/docker-compose

# Authorization

[root@docker /]# chmod +x /usr/local/bin/docker-compose

docker composejpg.jpg[root@docker /]# docker-compose --version

docker-compose version 1.25.4, build 8d51620a

[root@docker tools]# rz

[root@docker tools]# tar zxvf harbor-offline-installer-v1.5.0.tgz 

[root@docker tools]# cd harbor

image.png

[root@docker harbor]# mkdir ssl

4. The self-signed certificate TLS

[root@docker ssl]# openssl req    -newkey rsa:4096 -nodes -sha256 -keyout ca.key    -x509 -days 365 -out ca.crt

[root@docker ssl]# 

openssl req \

 -newkey rsa:4096 -nodes -sha256 -keyout reg.sky9899.com.key  \

 -out reg.sky9899.com.csr

[root@docker ssl]# ls

ca.crt  ca.key  reg.sky9899.com.csr  reg.sky9899.com.key

[root@docker ssl]#openssl x509 -req -days 365 -in  reg.sky9899.com.csr  -CA ca.crt -CAkey ca.key -CAcreateserial -out 

reg.sky9899.com.crt

[root@docker ssl]# ls

ca.crt  ca.key  ca.srl  reg.sky9899.com.crt  reg.sky9899.com.csr  reg.sky9899.com.key

5.Harbor Installation and Configuration

[root@docker harbor]# vi  harbor.cfg 

# Modify the following items to

hostname = reg.sky9899.com

ui_url_protocol = https

ssl_cert = ./ssl/reg.sky9899.com.crt

ssl_cert_key = ./ssl/reg.sky9899.com.key

harbor_admin_password = Harbor

[root@docker harbor]# ./prepare 

Generated and saved secret to file: /data/secretkey

Generated configuration file: ./common/config/nginx/nginx.conf

Generated configuration file: ./common/config/adminserver/env

Generated configuration file: ./common/config/ui/env

Generated configuration file: ./common/config/registry/config.yml

Generated configuration file: ./common/config/db/env

Generated configuration file: ./common/config/jobservice/env

Generated configuration file: ./common/config/jobservice/config.yml

Generated configuration file: ./common/config/log/logrotate.conf

Generated configuration file: ./common/config/jobservice/config.yml

Generated configuration file: ./common/config/ui/app.conf

Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt

The configuration files are ready, please use docker-compose to start the service.

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

[Step 0]: checking installation environment ...

Note: docker version: 19.03.8

Note: docker-compose version: 1.25.4

[Step 1]: loading Harbor images ...

52ef9064d2e4: Loading layer [============================>]  135.9MB/135.9MB

c169f7c7a5ff: Loading layer [=============================>]  154.2MB/154.2MB

a2194b3a5434: Loading layer [===========================>]  10.75MB/10.75MB

f3809b773329: Loading layer [============================>]  2.048kB/2.048kB

bdd2cd4d5394: Loading layer [============================>]  48.13kB/48.13kB

bce61638a813: Loading layer [============================>]   10.8MB/10.8MB

Loaded image: vmware/clair-photon:v2.0.1-v1.5.0

0bf5fb4e60f4: Loading layer [==============================>]     95MB/95MB

9fc876f7ef97: Loading layer [==============================>]  6.656kB/6.656kB

9f364ae08e7f: Loading layer [==============================>]  2.048kB/2.048kB

d8e3574f27f2: Loading layer [=============================>]   7.68kB/7.68kB

Loaded image: vmware/postgresql-photon:v1.5.0

8cb812a02f44: Loading layer [============================ >]  23.25MB/23.25MB

826629c35871: Loading layer [============================>]  15.36MB/15.36MB

68fc630fcd08: Loading layer [============================>]  15.36MB/15.36MB

Loaded image: vmware/harbor-adminserver:v1.5.0

fd8233cdfcf0: Loading layer [=============================>]  23.25MB/23.25MB

7ab0310b3d9d: Loading layer [===========================>]   2.56kB/2.56kB

75609935cf31: Loading layer [===========================>]   2.56kB/2.56kB

654b65c0f8ff: Loading layer [===========================>]  2.048kB/2.048kB

1da5c77da464: Loading layer [===========================>]   22.8MB/22.8MB

5e9191f65a4c: Loading layer [===========================>]   22.8MB/22.8MB

Loaded image: vmware/registry-photon:v2.6.2-v1.5.0

Loaded image: vmware/photon:1.0

454c81edbd3b: Loading layer [===========================>]  135.2MB/135.2MB

e99db1275091: Loading layer [============================>]  395.4MB/395.4MB

051e4ee23882: Loading layer [============================>]  9.216kB/9.216kB

6cca4437b6f6: Loading layer [=============================>]  9.216kB/9.216kB

1d48fc08c8bc: Loading layer [==============================>]   7.68kB/7.68kB

0419724fd942: Loading layer [==============================>]  1.536kB/1.536kB

543c0c1ee18d: Loading layer [==============================>]  655.2MB/655.2MB

4190aa7e89b8: Loading layer [============================>]  103.9kB/103.9kB

Loaded image: vmware/harbor-migrator:v1.5.0

1736beaf11c8: Loading layer [===============================>]  23.25MB/23.25MB

3026403c0282: Loading layer [===============================>]  24.39MB/24.39MB

1aaf4a794824: Loading layer [===============================>]  7.168kB/7.168kB

b427e1a2dd17: Loading layer [==============================>]  10.56MB/10.56MB

68906d88fd96: Loading layer [==============================>]  24.38MB/24.38MB

Loaded image: vmware/harbor-ui:v1.5.0

cf8fe5c86f4b: Loading layer [================================>]  78.26MB/78.26MB

d15d127e6aa2: Loading layer [==============================>]  3.072kB/3.072kB

9d47dbd3d824: Loading layer [===============================>]   59.9kB/59.9kB

098c90ca59f4: Loading layer [================================>]  61.95kB/61.95kB

Loaded image: vmware/redis-photon:v1.5.0

71a9f645bc2d: Loading layer [================================>]  4.755MB/4.755MB

Loaded image: vmware/nginx-photon:v1.5.0

c4c015394057: Loading layer [===============================>]  401.3MB/401.3MB

f9d78b9c2c97: Loading layer [===============================>]  9.216kB/9.216kB

5cf7df688ef1: Loading layer [===============================>]  9.216kB/9.216kB

9513efb6efc9: Loading layer [===============================>]   7.68kB/7.68kB

52252ffb5fc7: Loading layer [===============================>]  1.536kB/1.536kB

Loaded image: vmware/mariadb-photon:v1.5.0

243e37f674cb: Loading layer [=================================>]  23.25MB/23.25MB

eb85e1888b13: Loading layer [=================================>]  10.95MB/10.95MB

7b86ea27af2e: Loading layer [=================================>]   17.3MB/17.3MB

a876e7e90459: Loading layer [==================================>]  15.87kB/15.87kB

08c705395182: Loading layer [=================================>]  3.072kB/3.072kB

2cb9ada082da: Loading layer [=================================>]  28.24MB/28.24MB

Loaded image: vmware/notary-signer-photon:v0.5.1-v1.5.0

b9abce7219b5: Loading layer [================================>]  73.15MB/73.15MB

ee87a4f06084: Loading layer [=================================>]  3.584kB/3.584kB

Loaded image: vmware/harbor-log:v1.5.0

bed1e891c86f: Loading layer [===============================>]  3.072kB/3.072kB

Loaded image: vmware/harbor-db:v1.5.0

820ecb80c0fa: Loading layer [==============================>]  23.25MB/23.25MB

Loaded image: vmware/harbor-jobservice:v1.5.0

6ae72c7ad4ac: Loading layer [===============================>]  12.16MB/12.16MB

Loaded image: vmware/notary-server-photon:v0.5.1-v1.5.0

[Step 2]: preparing environment ...

Clearing the configuration file: ./common/config/adminserver/env

Clearing the configuration file: ./common/config/ui/env

Clearing the configuration file: ./common/config/ui/app.conf

Clearing the configuration file: ./common/config/ui/private_key.pem

Clearing the configuration file: ./common/config/db/env

Clearing the configuration file: ./common/config/jobservice/env

Clearing the configuration file: ./common/config/jobservice/config.yml

Clearing the configuration file: ./common/config/registry/config.yml

Clearing the configuration file: ./common/config/registry/root.crt

Clearing the configuration file: ./common/config/nginx/cert/reg.sky9899.com.crt

Clearing the configuration file: ./common/config/nginx/cert/reg.sky9899.com.key

Clearing the configuration file: ./common/config/nginx/nginx.conf

Clearing the configuration file: ./common/config/log/logrotate.conf

loaded secret from file: /data/secretkey

Generated configuration file: ./common/config/nginx/nginx.conf

Generated configuration file: ./common/config/adminserver/env

Generated configuration file: ./common/config/ui/env

Generated configuration file: ./common/config/registry/config.yml

Generated configuration file: ./common/config/db/env

Generated configuration file: ./common/config/jobservice/env

Generated configuration file: ./common/config/jobservice/config.yml

Generated configuration file: ./common/config/log/logrotate.conf

Generated configuration file: ./common/config/jobservice/config.yml

Generated configuration file: ./common/config/ui/app.conf

Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt

The configuration files are ready, please use docker-compose to start the service.

[Step 3]: checking existing instance of Harbor ...

[Step 4]: starting Harbor ...

Creating network "harbor_harbor" with the default driver

Creating harbor-log ... done

Creating harbor-db  ... 

Creating registry           ... error

Creating harbor-adminserver ... 

Creating redis              ... 

Creating harbor-db          ... done

ERROR: for registry  Cannot create container for service registry: Conflict. The container name "/registry" is already in use by 

contCreating harbor-adminserver ... done

Creating redis              ... done

ERROR: for registry  Cannot create container for service registry: Conflict. The container name "/registry" is already in use by 

container "b697d68647a95e01ee09115c3b9c035a393cac7e51f96e2e58c1896b500e8cfb". You have to remove (or rename) that container to be able 

to reuse that name.

ERROR: Encountered errors while bringing up the project.

#有存在容器重名的,也有宿主机占用了端口,导致端口冲突的,都会导致Harbor安装失败。

#只有解决不重名,或删除或停止冲突的容器,解决端口冲突的问题,才能成功安装Harbor。

#解决办法

[root@docker harbor]# docker stop registry && \

> docker rm -v registry

registry

registry

#停止宿主机80端口

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

[Step 0]: checking installation environment ...

Note: docker version: 19.03.8

Note: docker-compose version: 1.25.4

[Step 1]: loading Harbor images ...

Loaded image: vmware/clair-photon:v2.0.1-v1.5.0

Loaded image: vmware/postgresql-photon:v1.5.0

Loaded image: vmware/harbor-adminserver:v1.5.0

Loaded image: vmware/registry-photon:v2.6.2-v1.5.0

Loaded image: vmware/photon:1.0

Loaded image: vmware/harbor-migrator:v1.5.0

Loaded image: vmware/harbor-ui:v1.5.0

Loaded image: vmware/redis-photon:v1.5.0

Loaded image: vmware/nginx-photon:v1.5.0

Loaded image: vmware/mariadb-photon:v1.5.0

Loaded image: vmware/notary-signer-photon:v0.5.1-v1.5.0

Loaded image: vmware/harbor-log:v1.5.0

Loaded image: vmware/harbor-db:v1.5.0

Loaded image: vmware/harbor-jobservice:v1.5.0

Loaded image: vmware/notary-server-photon:v0.5.1-v1.5.0

.......................

[Step 3]: checking existing instance of Harbor ...

[Step 4]: starting Harbor ...

Creating harbor-log ... done

Creating harbor-adminserver ... done

Creating harbor-db          ... done

Creating registry           ... done

Creating redis              ... done

Creating harbor-ui          ... done

Creating nginx              ... done

Creating harbor job service ... donated

----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at https://reg.sky9899.com. 

For more details, please visit https://github.com/vmware/harbor .

6.Docker host access Harbor

docker-commpose.jpg

harbor.jpg

habor2.jpg

harbo3.jpg

# IP access can be used directly, it can also be accessed using the domain name.

# Do do on the local host domain name resolution, you can access, such as "C: \ Windows \ System32 \ drivers \ etc \ hosts"

#192.168.153.141   reg.sky9899.com

Guess you like

Origin blog.51cto.com/sky9896/2480453