Skip to content

Instantly share code, notes, and snippets.

@r0xen
Created May 10, 2020 11:36
Show Gist options
  • Save r0xen/8e5009d4d6a5ccdb478aff8097b4a34f to your computer and use it in GitHub Desktop.
Save r0xen/8e5009d4d6a5ccdb478aff8097b4a34f to your computer and use it in GitHub Desktop.
Private Docker Registry Behind Traefik 2.2 Configuration for Docker Swarm
version: "3.7"
services:
registry:
image: registry:2.7.1
networks:
- swarm_net
environment:
- REGISTRY_HTTP_ADDR=0.0.0.0:5000
- REGISTRY_HTTP_RELATIVEURLS=true
- REGISTRY_LOG_ACCESSLOG_DISABLED=false
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
labels:
- "traefik.enable=true"
- "traefik.tcp.routers.registry.entrypoints=registry"
- "traefik.tcp.routers.registry.rule=HostSNI(`*`)"
- "traefik.tcp.services.registry.loadbalancer.server.port=5000"
networks:
swarm_net:
external: true
version: "3.7"
services:
traefik:
image: traefik:2.2
networks:
- swarm_net
command:
- --api=true
- --providers.docker=true
- --providers.docker.swarmMode=true
- --providers.docker.exposedByDefault=false
- --entryPoints.private.address=:8000
- --entryPoints.registry.address=:5000
- --accesslog=true
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=private"
- "traefik.http.routers.traefik.rule=PathPrefix(`/private/traefik`) || PathPrefix(`/api`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
- "traefik.http.middlewares.traefik-strip.stripprefix.prefixes=/private/traefik"
- "traefik.http.routers.traefik.middlewares=traefik-strip@docker"
ports:
- target: 8000
published: 8000
mode: host
- target: 5000
published: 5000
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
swarm_net:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment