Skip to content

Instantly share code, notes, and snippets.

@joshuarubin
Last active August 29, 2015 14:19
Show Gist options
  • Save joshuarubin/b7c2e4e0e4d6501092b2 to your computer and use it in GitHub Desktop.
Save joshuarubin/b7c2e4e0e4d6501092b2 to your computer and use it in GitHub Desktop.
Docker Registry Mirror Unit File
[Unit]
Description=Docker Registry Mirror
[Service]
Restart=always
RestartSec=10
ExecStartPre=-/usr/bin/docker kill %p
ExecStartPre=-/usr/bin/docker rm %p
ExecStartPre=/usr/bin/docker pull registry
ExecStartPre=/usr/bin/sudo /usr/bin/mkdir -p /home/core/data/%p
ExecStart=/usr/bin/docker run \
--rm \
--name %p \
--publish 9000 \
--env STANDALONE=false \
--env REGISTRY_PORT=9000 \
--env MIRROR_SOURCE=https://registry-1.docker.io \
--env MIRROR_SOURCE_INDEX=https://index.docker.io \
--volume /home/core/data/%p:/tmp/registry \
registry
ExecStop=/usr/bin/docker stop %p
[X-Fleet]
MachineMetadata=%p=1
write_files:
- path: /etc/systemd/system/docker.service.d/50-registry-mirror.conf
content: |
[Service]
Environment=DOCKER_OPTS='--registry-mirror=http://$private_ipv4:9000'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment