Skip to content

Instantly share code, notes, and snippets.

@xynova
Last active June 7, 2016 01:51
Show Gist options
  • Save xynova/d99df6de8210e4c12df5e00cf3e194cb to your computer and use it in GitHub Desktop.
Save xynova/d99df6de8210e4c12df5e00cf3e194cb to your computer and use it in GitHub Desktop.
docker private registry mirroring
#PREPARE REGISTRY
#--------------------------------------
export REGISTRY_VERSION=2.4.0
# PULL REGISTRY
docker pull registry:${REGISTRY_VERSION}
# GENERATE CONFIG
docker run -it --rm --entrypoint cat registry:${REGISTRY_VERSION} /etc/docker/registry/config.yml > config.yml \
&& cat << EOF >> config.yml
proxy:
remoteurl: https://registry-1.docker.io
EOF
# START REGISTRY
docker run -d --restart=always \
-p 5000:5000 \
--name v2-mirror \
-v $(pwd)/config.yml:/etc/docker/registry/config.yml \
registry:${REGISTRY_VERSION}
# test =>
# curl -I http://172.17.4.10:5000/v2/curl -I http://172.17.4.10:5000/v2/
# curl http://172.17.4.10:5000/v2/_catalog
# Then on the docker hosts
# SET DOCKER OPTS
# DIR=/etc/systemd/system/docker.service.d
# sudo mkdir -p $DIR && cat << EOF | sudo tee "${DIR}/10-docker-opts.conf"
# [Service]
# Environment="DOCKER_OPTS=--registry-mirror=${LOCAL_REGISTRY_ENDPOINT} --insecure-registry=${LOCAL_REGISTRY_ENDPOINT}"
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment