3 Operation and maintenance-ubuntu16.04.6xenial-basic environment construction-docker integrated registry

1 installation

1 Create and enter the installation directory

mkdir -p /usr/local/docker/registry && cd /usr/local/docker/registry

2 Add compose file

vi docker-compose.yml

3 Add file content

The fronted management tool of the registry is used here, which is convenient for viewing the mirror information. You can directly enter the ip and port in the browser.
Mirror reference URL: https://hub.docker.com/

version: '3'
services:
    registry: 
        restart: always
        image:  registry
        container_name: registry
        ports:
            - 5000:5000
        volumes: 
            - ./data:/var/lib/registry
    
    frontend: 
        image: konradkleine/docker-registry-frontend:v2
        environment: 
            - ENV_DOCKER_REGISTRY_HOST=192.168.30.143
            - ENV_DOCKER_REGISTRY_PORT=5000
        ports: 
            - 81:80
        volumes:
            - ./certs/fronted.crt:/etc/apache2/server.crt:ro
            - ./certs/fronted.key:/etc/apache2/server.key:ro

4 Start the container

docker-compose up -d

5 View

  • View the mirror information when configuring fronted, directly enter the browser http://192.168.30.143:81to access
#查看全部镜像
curl -XGET http://192.168.30.143:5000/v2/_catalog
#查看指定镜像
curl -XGET http://192.168.30.143:5000/v2/registry/tags/list

2 configuration

2.1 Client configuration private server warehouse

1 Enter the configuration directory and modify the configuration file

cd /etc/docker	&& vi daemon.json

2 Add content to the configuration file

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

3 Restart verification (make sure no container is running before restarting)

systemctl restart docker && docker info	

3 Pull and push

3.1 Pull the image from the warehouse

docker pull registry	

3.2 Push the image to the warehouse

1 Mark the local mirror to point to the target warehouse

#标记命令
docker tag registry 192.168.30.143:5000/registry:latest
#重命名镜像命令(可不用)
docker tag imageName imageName:tag

2 Push the local image to the target warehouse

docker push 192.168.30.136:5000/registry:latest 

Guess you like

Origin blog.csdn.net/weixin_45544465/article/details/100012887