Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of Building Private Image Repository in Docker

Shulou Source: shulou.com Published: 2022-06-02 04:15:03 10月23日 Update

Like the management of Mavan, Dockers not only provides a central repository, but also allows us to build local private repositories using registry.

There are many advantages to using a private warehouse:

Save network bandwidth. For each image, you don't have to go to the central warehouse to download it, you only need to download it from the private warehouse. For images used within the company, push them to the local private warehouse for use by relevant personnel within the company.

Docker is becoming more and more useful, so today we want to build a private image repository to maintain our own internal images.

Environment

CentOS 7.xDocker 1.12.6

Install docker-distribution

$sudo yum install-y docker-distribution$ sudo systemctl enable docker-distribution$ sudo systemctl start docker-distribution

Use

Get test image

First get a container image for testing from the Docker central repository, where busybox is used as the test image.

$sudo docker pull busybox$ sudo docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/busybox latest 9d7e6df8e5ca 8 hours ago 1.129 MB

Mark and upload private images

We don't make any changes to busybox here, just change the name and use it as a private image.

$sudo docker tag busybox:latest localhost:5000/kongxx/mybusybox:latest$ sudo docker push localhost:5000/kongxx/mybusybox:latest

After the upload is complete, you can check it with the following command

$curl http://192.168.0.109:5000/v2/kongxx/busybox/tags/list{"name":"kongxx/busybox","tags":["latest"]}

In the meantime, let's take a look at the local image list.

$sudo docker imagesREPOSITORY TAG IMAGE ID CREATED SIZElocalhost:5000/kongxx/mybusybox latest 9d7e6df8e5ca 8 hours ago 1.129 MBdocker.io/busybox latest 9d7e6df8e5ca 8 hours ago 1.129 MB

Test the image repository

In order to access the private repository (https is not used because this is your own test), you also need to modify the Docker configuration file

Edit the / etc/sysconfig/docker file and add the OPTIONS parameter to it

-- insecure-registry 192.168.0.109

Then restart the Docker service

$sudo systemctl restart docker

In order to test, we first delete the original local image.

$sudo docker rmi docker.io/busybox$ sudo docker rmi localhost:5000/kongxx/mybusybox

Then get the image again, as follows:

$sudo docker pull 192.168.0.109:5000/kongxx/mybusyboxUsing default tag: latestTrying to pull repository 192.168.0.109:5000/kongxx/mybusybox... latest: Pulling from 192.168.0.109:5000/kongxx/mybusybox414e5515492a: Pull completeDigest: sha256:fbcd856ee1f73340c0b7862201b9c045571d1e357797e8c4c0d02a0d21992b80

You can see from the output that you can download the image from your own repository.

Other

Finally, if you want to query which images are in the private warehouse, I haven't found any good way to find them all at once, but you can query them through the following combination command.

First of all, query the image names on the private warehouse.

$curl-XGET http://192.168.0.109:5000/v2/_catalog{"repositories":["kongxx/mybusybox","mandy/mybusybox"]}

Then use the following command to see which versions of the image there are

# curl-XGET http://192.168.0.109:5000/v2//tags/list$ curl-XGET http://192.168.0.109:5000/v2/kongxx/mybusybox/tags/list{"name":"kongxx/mybusybox","tags":["latest"]}

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: Image warehouse private test central command query company at the same time file facet method no no personnel advantage content parameter just can be passed Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Shulou Technology Linux Redmi