Home >Operation and Maintenance >Docker >Specific methods to build docker private library

Specific methods to build docker private library

王林
王林forward
2020-12-11 17:09:127145browse

Specific methods to build docker private library

Preparation

server1, server2 (server1 serves as a private library server and server2 serves as a normal client)

(Related recommendations: docker Tutorial)

On server1

1. Download registry

docker pull registry:latest

2. Configure /etc/default/docker Because https requires a certificate password, etc. It is more complicated, so directly Just add insecure-registry

# 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 and save the private image

docker push server1:5000/redis

5.1. View the image pushed to the private warehouse

$ docker search 10.10.105.71:5000/tonybai/busybox/
Error response from daemon: Unexpected status code 404
但通过v2版本的API,我们可以实现相同目的:

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

On server2 (client)

Because it is mentioned in docker Registry , If the insecure registry mode is adopted, the Docker Daemon on all hosts that interact with the Registry must be configured with: –insecure-registry option. In addition to this mode, certificates can also be configured, which will not be explained here

1. Configuration-insecure-registry(centos:/etc/sysconfig/docker ubuntu:/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. Download

docker pull server1:5000/redis

3. Submit push

docker tag redis server1:5000/redis

docker push server1:5000/redis

The above is the detailed content of Specific methods to build docker private library. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete