Skip to content

Instantly share code, notes, and snippets.

@sshnaidm
Last active February 8, 2018 10:10
Show Gist options
  • Save sshnaidm/bd75f590fcd64d932f666143495db7b4 to your computer and use it in GitHub Desktop.
Save sshnaidm/bd75f590fcd64d932f666143495db7b4 to your computer and use it in GitHub Desktop.
#!/bin/bash
REGISTRY_PORT=5000
CACHE_DIR=$HOME/docker_cache
mkdir -p $CACHE_DIR
chmod a+rwX $CACHE_DIR
yum install docker -y
cat <<EOF >$CACHE_DIR/config.yml
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
proxy:
remoteurl: https://registry-1.docker.io
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
EOF
chmod a+rw -R $CACHE_DIR
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl stop firewalld # caution!
docker run -d --restart=always -p $REGISTRY_PORT:5000 --name proxy-v2-mirror -v $CACHE_DIR:/var/lib/registry:z registry:2 /var/lib/registry/config.yml
# Configure client aschmod a+rw -R $CACHE_DIR
#
sudo cat <<EOF >/etc/docker/daemon.json
{
"insecure-registries" : ["localhost:$REGISTRY_PORT"],
"registry-mirrors": ["http://localhost:$REGISTRY_PORT"]
}
EOF
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment