Detailed explanation of the construction and use of Docker private warehouse

Detailed explanation of the construction and use of Docker private warehouse

The image can be saved on hub.docker.com, but the network speed is relatively slow. It is a better solution to build a private public warehouse in the internal environment. Today we will build a private docker warehouse in practice.

Environmental Planning

Two machines are required: the server of the docker private server warehouse and the ordinary machine using docker. Both machines are ubuntu16 version servers, and the IP information is as follows:

Machine Name ip Function
docker-registry 192.168.119.148 Docker private warehouse server
docker-app 192.168.119.155 A normal server running Docker service

Prepare the Machine

In this practice, the above two machines are two virtual machines created on VMware, and the Docker service is installed on both. For detailed creation and installation process, please refer to "Kubernetes under Rancher 1: Building Standardized VMware Images". Remember to change the names of the two images in VMware to "docker-registry" and "docker-app" respectively to avoid mistakes later.

After the virtual machines are started, please modify the /etc/hostname file first, change the hostnames of the two machines to "docker-registry" and "docker-app" respectively, and then restart them with the reboot command;

Installing a private repository

Log in to the docker-registry machine (SecureCRT is recommended);

Execute the following command to start a registry container, which is used to provide private warehouse services:

docker run --name docker-registry -d -p 5000:5000 registry

Execute the docker ps command to view the container status, as shown below:


The container starts normally and provides external services by mapping port 5000 to port 5000 of docker-registry;

Execute the command curl -X GET http://127.0.0.1:5000/v2/_catalog. The response received is as follows. It is a json object, in which the value corresponding to repositories is an empty json array, indicating that there is no image in the repository at present:

{"repositories":[]}

OK, the private warehouse has been created and started. Now let's try to use it.

Support http protocol push

Normally, the application server uses https to push images to the warehouse. Here we use the command line to test the push using ordinary http, so we need to modify the docker startup parameters to allow it to work with the http protocol;

The machine that pushes the image is docker-app, so log in to this machine (SecureCRT is recommended);

Modify the /etc/default/docker file and add the following red box content:

Modify /lib/systemd/system/docker.service again. The content in the red box below, the first line is added, and the second line is modified:

Execute the following command to reload the configuration information and restart the Docker service:

systemctl daemon-reload;service docker restart

Push the image to a private repository

Next, we download an image in docker-app and then push the image to a private warehouse;

Log in to the docker-app machine (SecureCRT is recommended);

Execute the command docker pull tomcat to download the latest version of the tomcat image from hub.docker.com, as shown below:

After downloading, execute docker images to view the image information, as shown below:

As shown in the red box above, the ID of this image is 3dcfe809147d, so we execute the following command to add a tag with the private warehouse IP to this image so that it can be successfully pushed to the private warehouse later:

docker tag 3dcfe809147d 192.168.119.148:5000/tomcat

Then execute docker images to view the image information. As shown in the following figure, a new image appears, and REPOSITORY is 192.168.119.148:5000/tomcat:

Execute the following command to push:

docker push 192.168.119.148:5000/tomcat

You can see that it is progressing smoothly, as shown below:

After the push is successful, execute curl -X GET http://192.168.119.148:5000/v2/_catalog on docker-app and docker-registry respectively to view the image information of the private warehouse, and you can see the following content:

Using a private repository image

On the docker-app machine, first execute the following command to delete the local image:

docker rmi 192.168.119.148:5000/tomcat tomcat

Then execute the following command to create a container using the image on the private server and map port 8080:

docker run --name tomcat001 -p 8080:8080 -idt 192.168.119.148:5000/tomcat

If there is no local mirror, go to the private server to download, as shown below:

The IP of docker-app is 192.168.119.155, so open the browser on the current computer and enter: 192.168.119.155:8080, you can see the familiar tomcat welcome page as shown below:

This practical exercise is now over. I hope it can be helpful for building your private warehouse. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed process of installing and deploying onlyoffice in docker
  • Ubuntu Docker installation, deployment and simple application
  • Docker installation and deployment on CentOS7 system and basic tutorial
  • Detailed explanation of CentOS 7: Docker private warehouse construction and use
  • Detailed steps to build a Docker Registry private warehouse
  • Docker basic commands from installation to application deployment and private warehouse construction

<<:  Mysql5.7.14 Linux version password forgotten perfect solution

>>:  Detailed graphic explanation of Mysql5.7.18 installation and master-slave replication

Recommend

Detailed explanation of SSH password-free login configuration under Linux

Assume there are two Linux servers A and B, and w...

How to build a SOLO personal blog from scratch using Docker

Table of contents 1. Environmental Preparation 2....

Analysis of Nginx Rewrite usage scenarios and configuration methods

Nginx Rewrite usage scenarios 1. URL address jump...

Specific use of MySQL internal temporary tables

Table of contents UNION Table initialization Exec...

html opens a new window with a hyperlink and can control window properties

1. The window size opened by the HTML hyperlink C...

JavaScript knowledge: Constructors are also functions

Table of contents 1. Definition and call of const...

Installation tutorial of MySQL 5.1 and 5.7 under Linux

The operating system for the following content is...

Docker setting windows storage path operation

When installing Docker on Windows 10, after selec...

Learning to build React scaffolding

1. Complexity of front-end engineering If we are ...

Summary of methods to clear cache in Linux system

1) Introduction to cache mechanism In the Linux s...

Do you know why vue data is a function?

Official website explanation: When a component is...

CSS3 uses var() and calc() functions to achieve animation effects

Preview knowledge points. Animation Frames Backgr...