This is the seventh day of my participation in the August More text Challenge. For details, see: August More Text Challenge

When using K8S, you need to specify the image to be used. However, if you publish private projects such as SpringBoot, it may not be safe to publish the image to the network, so you need to install a local private warehouse and upload the image to the private warehouse for obtaining. Here we choose the common harbor in the market. In this article, the owner of the pro test, according to the steps can be executed.

1. Install the docker

Please refer to the previous article, not an overview.

2. Install the docker – compose

This is a mandatory plug-in and cannot be skipped.

The curl - L "https://get.daocloud.io/docker/compose/releases/download/1.27.3/docker-compose-$(uname - s) - $(uname -m)" - o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose // Validation versionCopy the code

3. Build Harbor

1. Download

Here we choose our home page, download the installation package on the browser to https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.4.tgz

2. Unzip

Tar ZXVF harbor - offline installer - v1.8.4. TGZCopy the code

3. Modify the configuration

Modify the following file

The current service IP address, service port, login account, and login password are specified.

4. Install

Execute.

./prepare
./install.sh
Copy the code

5. Verify

Access IP address: If the following page is displayed, the port is successfully accessed and the account password is admin/1234.

The port number, account number, and password are configured in the configuration file. Change the port number, account number, and password based on the configuration.

4. Configuration docker

When the installation is complete, we need to give Docker access to the harbor. Otherwise, you can’t upload or pull the image without a connection. Here we need to modify the Docker configuration file.

vi  /etc/docker/daemon.json
Copy the code
"Registry - mirrors" : "http://295c6a59.m.daocloud.io"], "insecure - registries:" [] "192.168.44.11:9000"Copy the code

Insecure -registries is the address and port configured above. Please modify it according to your own requirements.

Restart the Docker container

Systemctl daemon-reload systemctl restart Docker Restarts the dokcerCopy the code

Verify that Docker can connect to harbor

Docker Login 192.168.44.31:9000 # Enter the password admin/123456Copy the code

Successful login output:

5. Upload the image

1. Create a path for uploading the harbor

Harbor creates the following folder,Remember the path.

2. Upload the image

Docker images // View imagesCopy the code

We upload eureka to the Harbor warehouse.

Docker tag 02 d27f7b9531 192.168.43.33:9000 / electronic_government_project2. 0 / had been / / will play tag 02 d27f7b9531 mirror mirror id Electronic_government_project2. 0 for just the new folder docker push 192.168.43.33:9000 / electronic_government_project2. 0 / eureka // Push to harborCopy the code

Access the harbor path. If push mirror appears, push is complete.

6. Pull the mirror

Modify the docker configuration file as described above. After confirming that the harbor can be connected, execute the following statement:

Docker pull 192.168.48.35:9000 / electronic_government_project2. 0 / eurekaCopy the code

7. Restart the harbor

docker-compose stop
docker-compose up -d
Copy the code

Harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor harbor