Jenkins Push Mirror to Private docker-registry

  jenkins

Build docker-registry

Pull mirror

docker pull registry:2

Preliminary operation

docker run --rm -p 5000:5000 \
  -v /Users/xixicat/registry/data:/var/lib/registry \
  -v /Users/xixicat/registry/auth:/auth \
  registry:2

Access
http://192.168.99.100:5000/v2 …

Create account password

docker run --rm --entrypoint htpasswd registry:2 -Bbn admin admin > ~/registry/auth/htpasswd

Rerun

docker run --rm -p 5000:5000 \
  -v /Users/xixicat/registry/data:/var/lib/registry \
  -v /Users/xixicat/registry/auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
  registry:2

Add https

  • Create CA certificate

docker run --rm -e COMMON_NAME=xixicat.com -e KEY_NAME=domain -v /Users/xixicat/registry/certs:/certs centurylink/openssl
  • Set hosts

sudo vim /etc/hosts
192.168.99.100 xixicat.com
  • Installation certificate

sudo mkdir -p /etc/docker/certs.d/xixicat.com:5000
sudo cp /Users/xixicat/registry/certs/domain.crt /etc/docker/certs.d/xixicat.com:5000/ca.crt

Restart your docker-machine

docker-machine restart yun

Rerun registry

docker run --rm -p 5000:5000 \
      -v /Users/xixicat/registry/data:/var/lib/registry \
      -v /Users/xixicat/registry/auth:/auth \
      -v /Users/xixicat/registry/certs:/certs \
      -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt\
      -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
      -e "REGISTRY_AUTH=htpasswd" \
      -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
      -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
      registry:2

Whether the test is successful or not

docker login xixicat.com:5000

Jenkins Push docker Mirror

Executed in dockslave
图片描述

Push mirror
图片描述

Output log
图片描述

doc