Docker--Docker image warehouse

1. Build a private mirror warehouse

Building a mirror warehouse can be achieved based on the DockerRegistry officially provided by Docker.

Official website address:https://hub.docker.com/_/registry

(1) Simplified version of the mirror warehouse

Docker's official Docker Registry is a basic version of the Docker image warehouse, which has complete functions of warehouse management, but does not have a graphical interface.

The construction method is relatively simple, the commands are as follows:

docker run -d \
    --restart=always \
    --name registry	\
    -p 5000:5000 \
    -v registry-data:/var/lib/registry \
    registry

The command mounts a data volume registry-data to the /var/lib/registry directory in the container, which is the directory where the private image library stores data.

Visithttp://YourIp:5000/v2/_catalog to view the images included in the current private image service

(2) Version with graphical interface

Use DockerCompose to deploy DockerRegistry with a graphical interface. The command is as follows:

version: '3.0'
services:
  registry:
    image: registry
    volumes:
      - ./registry-data:/var/lib/registry
  ui:
    image: joxit/docker-registry-ui:static
    ports:
      - 8080:80
    environment:
      - REGISTRY_TITLE=传智教育私有仓库
      - REGISTRY_URL=http://registry:5000
    depends_on:
      - registry

(3) Configure Docker trust address

Our private server uses the http protocol, which is not trusted by Docker by default, so we need to make a configuration:

# 打开要修改的文件
vi /etc/docker/daemon.json
# 添加内容:
"insecure-registries":["http://192.168.150.101:8080"]
# 重加载
systemctl daemon-reload
# 重启docker
systemctl restart docker

2. Push and pull images

To push an image to a private image service, you must first tag it. The steps are as follows:

① Retag the local image, and the name prefix is ​​the address of the private warehouse: 192.168.150.101:8080/

docker tag nginx:latest 192.168.150.101:8080/nginx:1.0 

② Push the image

docker push 192.168.150.101:8080/nginx:1.0 

③ Pull the image

docker pull 192.168.150.101:8080/nginx:1.0 

Guess you like

Origin blog.csdn.net/qq_45672041/article/details/134931733