[Docker] Create a Docker private warehouse

1. Install a private image repository

Since we need to push to a private mirror warehouse later, we pre-installed it and used the private mirror warehouse Registry developed by Docker.

  • Download the Docker image of the Registry;

    docker pull registry:2
    
  • To use the Docker container to run the Registry service, you need to add environment variables REGISTRY_STORAGE_DELETE_ENABLED=trueto enable the function of deleting images;

    # --restart=always 表示开机启动
    docker run -p 5000:5000 --name registry2 \
    --restart=always \
    -e REGISTRY_STORAGE_DELETE_ENABLED="true" \
    -d registry:2
    
  • Modify the configuration file of Docker Daemon, the file location is /etc/docker/daemon.json, because Docker uses HTTPS to push images by default, but our mirror warehouse does not support it, so we need to add the following configuration to use HTTP push instead;

    {
          
          
      "insecure-registries": ["192.168.56.120:5000"]
    }
    

    Modify the ip address to the address where docker is located, if it is local, you can also use localhost

  • Finally, use the following command to restart the Docker service

    systemctl daemon-reload && systemctl restart docker
    

2. Mirror warehouse visualization

Since the management of private mirror warehouses is cumbersome, and docker-registry-uithere is a special page for convenient mirror management, we install it to manage private mirror warehouses.

  • Downloaded docker-registry-uiDocker image;

    docker pull joxit/docker-registry-ui:static
    
  • Use Docker containers to run docker-registry-uiservices;

    docker run -p 8280:80 --name registry-ui \
    --link registry2:registry2 \
    -e REGISTRY_URL="http://registry2:5000" \
    -e DELETE_IMAGES="true" \
    -e REGISTRY_TITLE="Registry2" \
    -d joxit/docker-registry-ui:static
    
  • Just find a docker image to test the availability of the private mirror warehouse we built (take busybox as an example)

    docker pull busybox
    
  • Label the image busyboxas a private warehouse, and set the version to v1.0;

    docker tag busybox localhost:5000/busybox:v1.0
    
  • Then push it to the private image warehouse;

    docker push localhost:5000/busybox:v1.0
    
  • Visit docker-registry-uithe management interface to view busyboxthe mirror, address: http://localhost:8280

3. References

My article: "How to check which versions of a Docker image.md"

My article: "Docker Setting Domestic Image Source.md"

My article: "Docker Quick Start Practical Tutorial.md"

My article: "Docker installs MySQL, Redis, RabbitMQ, Elasticsearch, Nacos and other common services.md"

My article: "Docker installs Nacos service.md"

My article: "How to modify the file.md in Docker"

My article: "Connection or communication between Docker containers.md"

My article: "How to persist database data with MySQL installed by Docker.md"

My article: "Making Docker Private Repository.md"

My article: "Using the docker-maven-plugin plug-in to build and publish push images to private warehouses.md"

My article: "Resolving Docker's failure to access port 9200 after installing Elasticsearch.md"


Portal: Nanny-style Spring5 source code analysis

Welcome to exchange technology and work life with the author

Contact the author

Guess you like

Origin blog.csdn.net/yuchangyuan5237/article/details/131971898