Using docker compose to build registry image management platform and use configuration

Time:2021-3-6

Introduction to docker registry

Docker hub is an image warehouse officially provided by docker to manage public images. We can pull the images we want from it or push our own images. But sometimes, when you can’t access the Internet or don’t want to push your own image to the public network, the docker registry can be used to store and manage your own image.

Install docker registry

  • establishdocker-compose.yml

    version: '3.1'
    services:
      registry:
        image: registry
        restart: always
        container_name: registry
        ports:
  volumes:
    - /usr/local/docker/registry/data:/var/lib/registry
-Start docker compose

$ docker-compose up -d

-Visit: http: // {IP}: 5000 / V2/

###Install docker registry UI

`After docker registry is successfully installed, it is not convenient to just view the images in the warehouse. You can use the 'Web UI' interface tool to manage the images, and 'docker registry frontend' is one of them

-Create ` docker- compose.yml `

version: ‘3.1’
services:

frontend:
  image: konradkleine/docker-registry-frontend:v2
  ports:
    - 8080:80
  volumes:
    - ./certs/frontend.crt:/etc/apache2/server.crt:ro
    - ./certs/frontend.key:/etc/apache2/server.key:ro
  environment:
    - ENV_DOCKER_REGISTRY_HOST={docker registy ip}
    - ENV_DOCKER_REGISTRY_PORT={docker registy port}
The above files need to be customized to modify the configuration

- `ENV_ DOCKER_ REGISTRY_ Host ': installed docker registry access IP
- `ENV_ DOCKER_ REGISTRY_ Port ': installed docker registry access port

-Start docker ccompose

$ docker-compose up -d

-Visit http: // {IP}: 8080] (http: // {IP}: 8080)

-Home page
  ![image](/img/bVbFV3f)
-Image list page
  ![image](/img/bVbFV3g)

###Configuring docker registry on Linux

-Editor` daemon.json `(New if not)

$ vi /etc/docker/daemon.json

The complete documents are as follows:

{

"registry-mirrors": [
  "{image accelerator address}"
],
"insecure-registries": [
  "{docker registry ip}:5000"
]

}

-Restart service

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

-Check whether the configuration is effective

$ docker info

The following contents show that the configuration is successful

Insecure Registries:
{docker registry ip}:5000
127.0.0.0/8

###Test push image

-Pull an image from docker hub public network

$ docker pull tomcat

-Mark that the image points to the docker registry private service warehouse

$ docker tag tomcat {docker registry ip}:5000/tomcat

-Push image to warehouse

$ docker push {docker registry ip}:5000/tomcat

###Test pull image

-Delete the image pulled from docker hub public network

$ docker image rm {docker registry ip}:5000/tomcat

-Pull image from docker registry private service

$ docker pull {docker registry ip}:5000/tomcat

END
-Author: Peng Chao
-  This article first appeared in personal blog[ https://antoniopeng.com/2019/10/08/docker/%E4%BD%BF%E7%94%A8DockerCompose%E6%90%AD%E5%BB%BARegistry%E9%95%9C%E5%83%8F%E7%AE%A1%E7%90%86%E5%B9%B3%E5%8F%B0%E5%8F%8A%E4%BD%BF%E7%94%A8%E9%85%8D%E7%BD%AE/ ]( https://antoniopeng.com/2019/10/08/docker/%E4%BD%BF%E7%94%A8DockerCompose%E6%90%AD%E5%BB%BARegistry%E9%95%9C%E5%83%8F %E7%AE%A1%E7%90%86%E5%B9%B3%E5%8F%B0%E5%8F%8A%E4%BD%BF%E7%94%A8%E9%85%8D%E7%BD%AE/)

Recommended Today

Rust and python: why rust can replace Python

In this guide, we compare the rust and python programming languages. We will discuss the applicable use cases in each case, review the advantages and disadvantages of using rust and python, and explain why rust might replace python. I will introduce the following: What is rust? What is Python? When to use rust When to […]