Skip to content

Instantly share code, notes, and snippets.

@makasim
Last active January 1, 2024 11:24
Show Gist options
  • Save makasim/6e7d45147ab8b1cdb5cf45bbb04ca1e9 to your computer and use it in GitHub Desktop.
Save makasim/6e7d45147ab8b1cdb5cf45bbb04ca1e9 to your computer and use it in GitHub Desktop.
Secure Docker Registry with Traefik and LetsEncrypt
version: '3.1'
services:
registry:
restart: always
image: registry:2
volumes:
- registry:/var/lib/registry
environment:
- REGISTRY_HTTP_ADDR=0.0.0.0:5000
networks:
- traefik_net
- default
deploy:
mode: 'global'
placement:
constraints:
- 'node.hostname == docker-registry'
labels:
- "traefik.port=5000"
- "traefik.docker.network=foobar_registry_traefik_net"
- "traefik.frontend.entryPoints=http,https"
- "traefik.frontend.redirect.entryPoint=https"
- "traefik.frontend.rule=Host:registry.foobar.com"
traefik:
image: traefik
ports:
- 80:80
- 443:443
- 8080:8080
command: traefik --docker --docker.swarmMode --docker.domain=traefik --docker.watch --api --logLevel="DEBUG" --debug --acme.acmelogging
networks:
- traefik_net
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /registry/traefik.toml:/etc/traefik/traefik.toml
deploy:
mode: 'global'
placement:
constraints:
- 'node.hostname == docker-registry'
volumes:
registry: ~
networks:
traefik_net:
driver: overlay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment