Recently, the company plans to use docker to manage the application. Because the company is an intranet environment, the image can only be imported into the Intranet environment through U SB flash disk. Although docker has image import and export, it will not be repeated here. However, if you want multiple people to use the image, you don't need everyone to import and export, so it's very necessary to have applications like hub.docker. Now I'll teach you how to build the Docker Registry private server.
For the Docker image operation required in this article, there are five common commands:
a. Pulling the image does not mean that the warehouse downloads it from hub.docker.io. Followed by the name of the image warehouse. If you want to specify a version, you can bring a tag. Otherwise, the latest version is downloaded by default: latest
docker pull [:tag]
b. List all images to get basic information about the image.
docker@default:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ldapaccountmanager/lam latest ea2e1f34792f 11 days ago 473MB osixia/openldap latest 4c780dfa5f5e 11 days ago 275MB 192.168.99.100:5000/tomcat 8 8973f493aa0a 3 weeks ago 508MB nginx latest e445ab08b2be 2 months ago 126MB registry latest f32a97de94e1 7 months ago 25.8MB osixia/openldap 1.2.2 1162356984fb 13 months ago 222MB jenkins latest cd14cecfdb3a 15 months ago 696MB 192.168.99.100:5000/docker-registry-web latest 0db5683824d8 3 years ago 599MB hyper/docker-registry-web latest 0db5683824d8 3 years ago 599MB
c. Delete the mirror. It can be deleted according to the image ID or the image warehouse name.
docker rmi <IMAGE ID>/<repo>
d. Mirror marking. This operation can be compared with Git marking, which is equivalent to releasing an available image version.
docker tag <repo> <new_repo>[:tag]
e. Image push. Similarly, you can learn from the push operation in the Git field to push the packaged image to the remote warehouse (i.e. Docker Registry).
docker push <new_repo>[:tag]
Set up docker Registry
1. Download the registry image
docker@default:~$ docker pull registry:latest latest: Pulling from library/registry Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146 Status: Image is up to date for registry:latest docker.io/library/registry:latest
2. Map the 5000 port. It is recommended that the data involved in the application be taken out separately to facilitate subsequent migration. This is how we mount
Map / var/lib/registry to local
docker run -d \ -p 5000:5000 \ -v /mnt/sda1/data/registry:/var/lib/registry \ --restart=always \ --name registry \ registry:latest
3. Executable
curl http://localhost:5000/v2/_ Catalog to view the existing image source
curl http://localhost:5000/v2/_catalog {"repositories":["docker-registry-web","tomcat"]}
Because I mounted the path, "docker registry Web" and "tomcat" before, the first installation should be:
{"repositories":[]}
4. Upload local image
First label the downloaded image:
docker@default:~$ docker tag osixia/openldap:latest localhost:5000/openldap docker@default:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE ldapaccountmanager/lam latest ea2e1f34792f 11 days ago 473MB osixia/openldap latest 4c780dfa5f5e 11 days ago 275MB localhost:5000/openldap latest 4c780dfa5f5e 11 days ago 275MB nginx latest e445ab08b2be 2 months ago 126MB registry latest f32a97de94e1 7 months ago 25.8MB osixia/openldap 1.2.2 1162356984fb 13 months ago 222MB jenkins latest cd14cecfdb3a 15 months ago 696MB hyper/docker-registry-web latest 0db5683824d8 3 years ago 599MB
Use the docker push command to push the image up
docker@default:~$ docker push localhost:5000/openldap:1.6 The push refers to repository [localhost:5000/openldap] c1e054ea9d45: Pushed 568aa872bd8c: Pushed 0b197c944734: Pushed 73850ae3a7fa: Pushed 8b349d954bf0: Pushed c53a68b5c449: Pushed 975729059892: Pushed 917bac618cd7: Pushed 1c95c77433e8: Pushed 1.6: digest: sha256:eaefde9d33b03fe04d081767fda7d3c3500ec861108bbdd19c1b5ceb76e3ee27 size: 2201
curl http://localhost:5000/v2/_ Catalog to view the existing image source
docker@default:~$ curl http://localhost:5000/v2/_catalog {"repositories":["docker-registry-web","openldap","tomcat"]}
Multiple versions of the same application can also be uploaded
docker@default:~$ docker tag osixia/openldap:1.2.2 localhost:5000/openldap:1.2.2 docker@default:~$ docker push localhost:5000/openldap:1.2.2 The push refers to repository [localhost:5000/openldap] 48cbdf93727e: Pushed c6894eace047: Pushed 7c14592fd5a1: Pushed b87f1a44d0b3: Pushed 49e27c1e677c: Pushed 8a72149f7317: Pushed 25751a7c5182: Pushed cdb3f9544e4c: Pushed 1.2.2: digest: sha256:34661cfeffa84d925eb3d15a835d8836fbccf3daba3459e930f8b16e35cfeb1f size: 1994 docker@default:~$ curl http://localhost:5000/v2/_catalog {"repositories":["docker-registry-web","openldap","tomcat"]}
But I can't see which versions of the same application are available
By checking the mount disk information, it can be seen that multiple versions have been uploaded
/mnt/sda1/data/registry/docker/registry/v2/repositories/openldap/_manifests/tags$ ls 1.2.2 1.6
In addition, Alibaba cloud has built:
https://blog.csdn.net/lilygg/article/details/88647082