Welcome to my GitHub
https://github.com/zq2599/blog_demos
content: classification summary of all original articles and supporting source code, involving Java, Docker, Kubernetes, DevOPS, etc.;
Cause is laziness
Recently tossing about docker at home, I need a private mirror warehouse harbor. The usual practice is to turn on the computer, start the harbor, and then turn off the computer when it is used up. I always find these operations to be troublesome (Do you want to call me lazy? You are right...)
Synology solves troubles
- There is a Synology DS218+ at home, which never shuts down and provides stable picture and video services for the whole family. Maven private server and MySQL have been deployed on it before, and it runs very stably. Let’s deploy harbor on it today, and you can always use it in the future. Use it as you want, it's a lazy savior.
- The picture below shows the appearance of DS218+ just bought. Two NAS hard drives have been in stable service:
- The following picture is the memory module purchased online. Now there are a total of 2+8=10G memory. Adequate memory is the confidence to dare to toss:
Previous link
Previous record of tossing Group Hui:
- Synology DS218+ deploys mysql
- Synology DS218+ deploys kafka
- Synology DS218+ do maven private server (nexus3)
- K8S uses Synology DS218+ NFS
Ideas
In fact, the operation is very simple: the deployment of harbor is based on docker-compose, and Synology already has docker-compose. Just follow the official deployment guide. The following points should be noted:
- Administrator rights are required in the deployment script, so it is not operated on the web page, but SSH login to the background to operate;
- If you use it at home, you don’t need https, just use http;
Environmental information
- Synology System: DSM 6.2.2-24922 Update 4
- harbor:1.10.3
Allow SSH login
First, you must set to allow SSH background login:
- The operation in the red box as shown below:
- As shown in the figure below, check the Enable SSH function and use 22 as the port:
- Now you can log in to Synology with the SSH terminal. I used Xshell6 to log in on a windows computer. You can choose any SSH terminal tool. The account password is the account password that can log in to Synology. As shown in the figure below, after logging in, you can Use the daily linux commands:
- Pay attention to the red box in the figure above, the home directory of the login account is /var/services/homes/zq2599
Deploy harbor
- Execute the following script to create the necessary directories and download and decompress the harbor installation package:
mkdir ~/harbor-1.10.3 \
&& mkdir ~/harbor-1.10.3/log \
&& mkdir ~/harbor-1.10.3/data \
&& mkdir ~/harbor-1.10.3/data/secret \
&& cd ~/harbor-1.10.3 \
&& wget https://github.com/goharbor/harbor/releases/download/v1.10.3/harbor-online-installer-v1.10.3.tgz \
&& tar -zxvf harbor-online-installer-v1.10.3.tgz \
&& mkdir -p ~/harbor-1.10.3/harbor/common/config
- Open the file ~/harbor-1.10.3/harbor/harbor.yml , there are the following points that need to be modified;
- Modify hostname , use domain name if there is a domain name, otherwise change to IP address:
- Choose an unoccupied port as the http port, here I use 5888
- If you do not plan to use https, you must comment all the https configuration:
- Modify the location of the stored data, note that /var/services/homes/zq2599 is the home directory of the current account:
- Modify the log storage path, this folder was created before:
- After modifying the configuration, save;
- Execute preparation commands:
cd ~/harbor-1.10.3/harbor \
&& sudo ./prepare
- start installation:
cd ~/harbor-1.10.3/harbor \
&& sudo ./install.sh
- The console output of a successful operation is as follows:
Browser login harbor
- Open the browser, visit the address http://192.168.50.43:5888 , account admin , password Harbor12345
- The login is successful as shown below, and Synology Space is still abundant:
Use harbor
- The next operation is to remotely push the image to the harbor machine from another Linux computer (hereinafter referred to as computer A);
- If you want to connect to the harbor server from computer A, you need to set up computer A. Computer A here is a Linux operating system;
- Edit the /etc/docker/daemon.json file of computer A (create it if it does not exist), add the content in the red box in the figure below, 192.168.50.43 is the IP address of the harbor server, and 5888 is the http port configured earlier:
- Restart the docker service to make the configuration effective:
systemctl daemon-reload \
&& systemctl restart docker
- Remind again: The modification here is the configuration of the machine connecting to the Harbor service remotely, not the configuration of the Harbor server ;
- On computer A, there is an nginx mirror with id 2622e6cca7eb , as shown in the figure below:
- Tag the image according to the rules of the dockr mirror repository:
docker tag 2622e6cca7eb 192.168.50.43:5888/library/nginx:latest
- Now it is a mirror image of the same ID, but there are two tags:
- Log in to harbor:
docker login 192.168.50.43:5888 -u admin -p Harbor12345
- Push the image to harbor:
docker push 192.168.50.43:5888/library/nginx:latest
- Successful operation:
- After the push is successful, this image can be seen on the browser page:
- The operation of creating a new warehouse is as follows:
- Created successfully:
Uninstall harbor
- If you don't need harbor, just execute the following command:
cd ~/harbor-1.10.3/harbor \
&& sudo docker-compose down
- Then delete the entire ~/harbor-1.10.3 directory, and note that all data will be deleted ;
At this point, the deployment and verification of the harbor for Synology DS218+ is complete, and I hope to bring you some reference;