Ali cloud using the ECS server build Docker public warehouse


Docker Docker warehouse mainly used for storage mirroring, Docker warehouse is divided into public and private warehouses warehouse
private warehouse: is built in LAN docker Warehouse
Public Warehouse: is built in the public network docker warehouse
Note: We use a cloud Ali today ECS server to build a public warehouse

Warehouse building process

Experimental environment: an ECS server 39.97.176.117

1, installation, start docker

yum install docker -y
systemctl restart docker
docker -v

2、docker下载registry、busybox

registry purposes: official Docker Registry to build a warehouse
busybox use: we need to build this image uploaded to your warehouse, you can download it from the warehouse

docker search busybox
docker pull docker.io/busybox
docker search registry
docker pull docker.io/registry

3, the mirror to rename busybox

docker tag docker.io/busybox 39.97.176.117:5000/busybox:v2

4, start the registry mirror

docker run -itd -p 5000:5000 -v /data/registry/:/var/lib/registry/ docker.io/registry

5, to start image uploaded busybox registry container

docker push 39.97.176.117:5000/busybox:v2
(1) results are given:
The push refers to a repository [39.97.176.117:5000/busybox]
Get https://39.97.176.117:5000/v1/_ping: http: server gave HTTP response to HTTPS client
(2) edit the docker main configuration file: / etc / sysconfig / docker

Add the following information:

#允许不安全仓库39.97.176.117
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 39.97.176.117:5000'
#添加仓库39.97.176.117
ADD_REGISTRY='--add-registry 39.97.176.117:5000'

Here Insert Picture Description

(3) Restart docker container:
systemctl restart docker

docker ps -a
docker start e3e16ba24caf #启动registry仓库docker容器

Note: You can now re-docker push up! Enough
Here Insert Picture Description

6, download the image from busybox build their own warehouse

Note: You need to download the same docker in the mirror first before downloading deleted

docker rmi -f 39.97.176.117:5000/busybox:v2
docker pull busybox:v2
#下载的时候不用写docker pull 39.97.176.117:5000/busybox:v2

Here Insert Picture Description

7, where we downloaded image is stored in it?

NOTE: In step 4, we do -v mapping, so you can see from the two places!

yum install tree -y
#宿主机:
tree /data/registry/

#registry仓库的docker虚拟机:
tree /var/lib/registry/

Note: -v only one-way mapping from the virtual machine's files are subject to change mapped to host files, delete files will not affect the virtual machines in the host machine, so if you want to delete the repository mirroring, you need docker container to a warehouse in the registry to delete the appropriate directory!

8, public warehouse + Nginx Reverse Proxy

Because we are using a public address, just now in the country which have been networked hosts can download the image of the warehouse! Modify the host's / etc / sysconfig / docker file to add it to the warehouse!

Warehouse optimization tips:

首先我们可以做nginx+openssl做一个https,这样就不用添加"--insecure-registry"这个参数了

nginx Virtual Host Configuration:
Here Insert Picture DescriptionNote: something like this would not have -p port mapping, and then all of the above steps inside 39.97.176.117 need to change www.wujincheng.xyz, / etc / sysconfig / docker file which also need to change 39.97. 176.117 is www.wujincheng.xyz.

He published 188 original articles · won praise 150 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_44571270/article/details/104428475