Skip to content

Instantly share code, notes, and snippets.

@euikook
Last active October 2, 2018 05:43
Show Gist options
  • Save euikook/5b5cfca04bb50426cbd4d6d9ea589ec5 to your computer and use it in GitHub Desktop.
Save euikook/5b5cfca04bb50426cbd4d6d9ea589ec5 to your computer and use it in GitHub Desktop.
Private Docker Registry

Append test.hub to /etc/hosts (each docker host include registry server)

echo "192.168.3.100 test.hub" | sudo tee -a /etc/hosts

Generate self-signed certificates

openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/test.hub.key \
-x509 -days 365 -out ./certs/test.hub.crt

Copy test.hub.crt to each docker host include registry server

sudo mkdir -p /etc/docker/certs.d/test.hub
sudo cp test.hub.crt /etc/docker/certs.d/test.hub

Run private docker registry with tcp port 433

docker run -d \
  --restart=always \
  --name registry \
  -v `pwd`/certs:/certs \
  -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
  -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/test.hub.crt \
  -e REGISTRY_HTTP_TLS_KEY=/certs/test.hub.key \
  -p 443:443 \
  registry:2

Verification

docker pull mongo
docker tag mongo test.hub/mongo
docker push test.hub.mongo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment