Docker Registry quickly build private image warehouse

A. Software Environment

The host operating system: CentOS Linux release 7.5

Virtual Machine Tool: VMware® Workstation 10

Application container Engine: Docker version 19.03.7

Mandate background

The so-called private warehouse, which is in local (LAN) is similar to a public warehouse build something, build a good following, we can submit to mirror the private warehouse. We both use to run our project Docker image, but also to avoid the public to come and collect the warehouse to take the risk of being exposed to; use Docker Registry quickly build private mirroring warehouse .

III. Procedure

Warehouse Address: 192.168.153.141

Download registry Mirror #

[root@docker docker]# docker pull registry

# Create a registry container and start

[root@docker docker]# docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 

--restart=always --name registry registry

b697d68647a95e01ee09115c3b9c035a393cac7e51f96e2e58c1896b500e8cfb

[root@docker docker]# docker ps

CONTAINER ID       IMAGE           COMMAND               CREATED                          STATUS         PORTS            NAMES

b697d68647a9       registry        "/entrypoint.sh /etc…"   40 seconds ago      Up 19 seconds   0.0.0.0:5000->5000/tcp   registry

Client: 192.168.153.142

# Test, all mirrors to view mirror warehouse

[root@redis_master docker]# curl http://192.168.153.141:5000/v2/_catalog

{"repositories":[]}

# Private Mirror Warehouse Management

# Configure a private warehouse:

# We /etc/docker/dameon.jsp

{

"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"],

 "insecure-registries":["192.168.153.141:5000"]

}

~

# systemctl restart docker

Download Mirror #

# docker pull nginx:1.12

Playing tag #

# docker tag nginx:1.12 192.168.153.142:5000/centos:7

# docker tag nginx:1.12 192.168.153.141:5000/nginx:1.12

# docker images

REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE

192.168.153.141:5000/nginx    1.12       4037a5562b03        22 months ago       108 MB

192.168.153.142:5000/centos   7           4037a5562b03        22 months ago       108 MB

docker.io/nginx               1.12                4037a5562b03        22 months ago       108 MB

# Upload the image to the warehouse

# docker  push 192.168.153.141:5000/nginx:1.12

The push refers to a repository [192.168.153.141:5000/nginx]

4258832b2570: Pushed 

683a28d1d7fd: Pushed 

d626a8ad97a1: Pushed

1.12: digest: sha256:09e210fe1e7f54647344d278a8d0dee8a4f59f275b72280e8b5a7c18c560057f size: 948

# docker tag nginx:1.12  192.168.153.141:5000/centos:7

# View Mirror warehouse

[root@redis_master /]# curl http://192.168.153.141:5000/v2/_catalog

{"repositories":["centos","nginx"]}

# List mirrored label

[root@redis_master /]# curl http://192.168.153.141:5000/v2/nginx/tags/list

{"name":"nginx","tags":["1.12"]}

# curl http://192.168.153.141:5000/v2/centos/tags/list

{"name":"centos","tags":["7"]}

#从本地仓库(192.168.153.141:5000)下载镜像

#并创建nginx容器

[root@redis_master /]# docker run -itd --name nginx -p 88:80 192.168.153.141:5000/nginx:1.12

0c75bba5a04eb075d432f4409923007a4f8c29b4fb987475d37cae4eeccb303b

#查看正在运行的容器

[root@redis_master /]# docker ps

CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                NAMES

0c75bba5a04e        192.168.153.141:5000/nginx:1.12   "nginx -g 'daemon ..."   40 seconds ago      Up 38 seconds       0.0.0.0:88->80/tcp   nginx

本地镜像查收.jpg

Guess you like

Origin blog.51cto.com/sky9896/2479368