Construction and Implementation of docker Private Library

  • 2021-09-20 21:58:06
  • OfStack

Installing and deploying a proprietary Docker Registry is a must for introducing, learning, and using the Docker technology. Especially when Docker is accepted by the organization and more people, projects and products begin to contact and use Docker, it is just necessary to store and distribute homemade Docker image. Docker Registry1 inherits the characteristics of "Docker has many pits" as before. Therefore, I will record the steps and problems encountered in the process of building "various" Registry for my own reference.

Registry2 not only supports local disks in mirror storage, but also supports many mainstream third-party storage schemes. You can also implement a distributed Docker Registry service with a distributed storage system.

Prepare

server1, server2 (where server1 is the private library server and server2 is the normal client)

On server1

1 Download registry


docker pull registry:latest

2 Configuration/etc/default/docker Because https requires certificate password, etc. It is complicated to add insecure-registry directly


# Docker Upstart and SysVinit configuration file

# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="--insecure-registry 127.0.0.1:5000"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"

3 Start registry


sudo docker run --name registry -d -p 5000:5000 -v /home/docker_registry:/var/lib/registry --restart=always registry:latest

4 tag Image


docker tag redis server1:5000/redis

5 Push to save private image


docker push server1:5000/redis

5.1 View images pushed to private repositories


$ docker search 10.10.105.71:5000/tonybai/busybox/
Error response from daemon: Unexpected status code 404
 But through v2 Version of API We can achieve the same goal: 

$curl http://10.10.105.71:5000/v2/_catalog
{"repositories":["tonybai/busybox"]}

On server2 (client)

Because it is said in docker Registry that if the mode of insecure registry is adopted, Docker Daemon on all hosts interacting with Registry should be configured with insecure-registry option. In addition to this mode, you can configure certificates, which are not explained here

1 Configuration-insecure-registry (centos:/etc/sysconfig/ES80ubuntu:/etc/default/docker)


# Docker Upstart and SysVinit configuration file

# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="--insecure-registry server1:5000"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"

2 downloads


docker pull server1:5000/redis

3 Submit Push


docker tag redis server1:5000/redis
docker push server1:5000/redis

Reference:
http://www.cnblogs.com/xcloudbiz/articles/5526262.html


Related articles: