Creating docker image warehouse with Harbor

Keywords: Operation & Maintenance Docker yum vim github

1. Why use Harbor

  1. Harbor is open source, free software

  2. Harbor is for enterprise users

  3. Harbor has a friendly WEB management interface


II. Harbor Official Resources

https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
https://github.com/goharbor/harbor/releases


Prerequisite 1: Installation of docker

Delete the old version of docker-ce

# yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

2. Installing dependency packages

# yum install -y yum-utils device-mapper-persistent-data lvm2

Import repo warehouse

# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

4. Install docker-ce

# yum install docker-ce docker-ce-cli containerd.io -y

5. Configure Ali Cloud Mirror Acceleration (optional)

# vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"]
}

6. Start docker service

# systemctl daemon-reload
# systemctl start docker
# systemctl enable docker


Prerequisite 2: Install docker-compose

Download docker-compose executable file

# curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. Give docker-compose executable rights

# chmod +x /usr/local/bin/docker-compose

3. Test and query the current version of docker-compose

# docker-compose --version


V. Installation and Configuration of Harbor

1. The Harbor installation package is divided into online installation and offline installation. This time, through online installation, the online installation file is downloaded through the Web page and then decompressed.

# tar xvf harbor-online-installer-<version>.tgz

2. Modify the harbor.yml configuration file

# vim harbor.yml
hostname: 192.168.0.131  #Write host name or IP address
http:
  port: 80
harbor_admin_password: Harbor12345  #UI initializes admin password, which can be modified after login
database:
  password: root123
data_volume: /data  #Local data storage location
log:  #Log configuration
  level: info
  rotate_count: 50
  rotate_size: 200M
  location: /var/log/harbor

3. Installation of harbor

# ./install.sh
		
###The following docker image file will be downloaded for reference only
REPOSITORY                             TAG                     
goharbor/redis-photon                  v1.8.0                  
goharbor/harbor-registryctl            v1.8.0                  
goharbor/registry-photon               v2.7.1-patch-2819-v1.8.0
goharbor/nginx-photon                  v1.8.0                  
goharbor/harbor-log                    v1.8.0                  
goharbor/harbor-jobservice             v1.8.0                  
goharbor/harbor-core                   v1.8.0                  
goharbor/harbor-portal                 v1.8.0                  
goharbor/harbor-db                     v1.8.0                  
goharbor/prepare                       v1.8.0

4. Start or close harbor

# cd /PATH/harbor_install_dir/
# docker-compose start
# docker-compose stop
# docker-compose ps

5. Modify the harbor configuration and re-apply and restart

# docker-compose down -v
# vim harbor.yml
# ./prepare
# docker-compose up -d

6. Delete harbor completely

# cd /PATH/harbor_install_dir/
# docker-compose down -v
# rm -r /data/database
# rm -r /data/register


6. Docker Client Configuration

1. docker host adds harbor warehouse address

# vim /etc/docker/daemon.json
{
  "insecure-registries": ["harbor_server_ip:80"]
}
# systemctl daemon-reload
# systemctl restart docker

2. Testing, uploading local images to harbor warehouse

# docker login harbor_server_ip
# docker pull hello-world
# docker tag hello-world:latest harbor_server_ip:80/library/hello-world:latest
# docker push harbor_server_ip:80/library/hello-world:latest

3. WEB landing address and default user password

http:harbor_server_ip

Username: admin
Password: Harbor12345


Posted by bennyboywonder on Wed, 02 Oct 2019 15:53:20 -0700