Detailed steps to build a local private warehouse on Docker on Ubuntu 17.10

Environmental preparation

Environment: Two Ubuntu virtual machines with Docker

Virtual machine one: 192.168.231.131 user development machine

Virtual machine two: 192.168.231.133 is used as a private warehouse

Here we have prepared two virtual machines, each with Docker installed , of which 131 machines are used as development machines and 133 machines are used as registry private warehouse machines. After the environment is ready, we will start building a private image repository.

Please refer to: Install Docker on Ubuntu 17.10

https://blog.csdn.net/michaelehome/article/details/79874787

Build a private warehouse

First download the registry image on the 133 machine , and specify a local directory /opt/data/registry to mount to the container's /tmp/registry , as follows:


1

$ sudo docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry



You can see that we started a container with the address: 192.168.231.133:5000

Enter http://localhost:5000/v2/_catalog to see that the current warehouse is empty:

Next we need to push a local image to the private repository

Pull a relatively small image under the 131 machine to test (use busybox here )


1

$ sudo docker pull busybox

 

Next, modify the tag of the image


1

$ sudo docker tag busybox 192.168.231.133:5000/busybox

 

Next, upload the tagged image to the private server


1

$ sudo docker push 192.168.231.133:5000/busybox

 

The above prompt appears, indicating that the local warehouse uses https by default for uploading. If it is connected through a non- https , the above prompt will appear.

In order to solve this problem, you need to increase the startup parameters when starting the docker server

Modify the docker startup configuration file (here is to modify the configuration of the 131 machine) The location of the configuration file under Ubuntu17.10 is: /lib/systemd/system/docker.service

Add --insecure-registry192.168.231.133:5000 to it as follows:


1

$ sudo vi /lib/systemd/system/docker.service

After the modification, restart the Docker service


1

$ sudo service docker stop

2

$ sudo service docker start

 

It can be seen that after the restart, we run the push command again, and the local image is successfully pushed to the local warehouse

1

$ sudo docker push 192.168.231.133:5000/busybox

View the local warehouse: busybox has been pushed to the local warehouse.

Next, we delete the local mirror above 133

 

1

$ sudo docker images

2

$ sudo docker rmi 192.168.231.133:5000/busybox:latest

3

$ sudo docker rmi busybox:latest

 

Deleted the local mirror, then we downloaded the mirror from the private mirror repository


1

$ sudo docker pull 192.168.231.133:5000/busybox

 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325890481&siteId=291194637