docker private warehouse Harbor

Keywords: Linux Docker yum MySQL CentOS

I. download and installation of relevant software

#Docker installation
wget  -O /etc/yum.repos.d/docker-ce.repo   https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install docker-ce -y
systemctl start docker && systemctl enable docker
#Docker compose installation
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#Harbor Download
wget  --continue https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-offline-installer-v1.6.3.tgz
tar xf harbor-offline-installer-v1.6.3.tgz
cd  harbor

II. Harbor configuration

#In order to configure https, Mr. Cheng's certificate
mkdir -pv /data/cert/
openssl genrsa -out /data/cert/server.key 2048
openssl req -x509 -new -nodes -key /data/cert/server.key -subj "/CN=10.6.19.40" -days 3650 -out /data/cert/server.crt #Replace ip if hostname
ll -a  /data/cert
#Edit configuration
#vim harbor.cfg
hostname = 10.6.19.40 #Or use a host name that can be resolved
ui_url_protocol = https
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
#When you perform the installation of harbor, you will start to download the dependent images according to the docker-compose.yml in the current directory, detect and start the services in order
./install.sh
 #Install vulnerability scanning at the same time
#./install.sh --with-clair
 #View the password of the initial admin account, and open https://10.6.19.40 to log in
cat harbor.cfg |grep harbor_admin_password
 Other optional configurations

#Modify port to 8080
#vim docker-compose.yml
ports:
      - 8080:80

III. Harbor management

#Use docker compose Management (must be in the same directory as docker compose.yml)
docker-compose --help
sudo docker-compose stop
sudo docker-compose start
sudo docker-compose ps
#To change the configuration of Harbor, first stop the existing Harbor instance and update harbor.cfg
docker-compose down -v
vim harbor.cfg
#Then run the prepare script to populate the configuration. Finally, recreate and start an instance of Harbor
./prepare
docker-compose up -d
#docker-compose -f docker-compose.yml up -d
#Delete Harbor's container, and keep the image data and Harbor's database file on the file system:
docker-compose down -v
#Delete Harbor's database and image data (for clean reinstallation):
rm -r /data/database
rm -r /data/registry

IV. Harbor image management

1. Harbor new test project

2. Client settings:

#vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://dwsyrsrh.mirror.aliyuncs.com"],
  "insecure-registries": ["10.6.19.40"]
}

3. Restart docker and log in to the image warehouse

systemctl restart docker
docker login 10.6.19.40

4. Label and upload the image to the warehouse

docker tag mysql:5.6 10.6.19.40/test/mysql:5.6
docker push 10.6.19.40/test/mysql:5.6
#docker pull 10.6.19.40/test/mysql:5.6

V. copy image

1. Create a new target in warehouse management

2. Create a new rule in replication management

Vi. installation of vulnerability scanning

./prepare --with-clair
docker-compose down
docker-compose -f docker-compose.yml -f docker-compose.clair.yml up -d


Posted by jerdo on Tue, 03 Dec 2019 02:07:06 -0800