Skip to content

Instantly share code, notes, and snippets.

@marcelo-ochoa
Last active August 25, 2023 16:28
Show Gist options
  • Save marcelo-ochoa/ff426a7cf571bb6d23bef2b2561aff16 to your computer and use it in GitHub Desktop.
Save marcelo-ochoa/ff426a7cf571bb6d23bef2b2561aff16 to your computer and use it in GitHub Desktop.
Traefik plus Portainer stack
version: "3.6"
services:
whoami:
image: traefik/whoami:v1.6.0
deploy:
mode: replicated
replicas: 1
labels:
- traefik.enable=true
- traefik.docker.network=lb_network
- traefik.constraint-label=traefik-public
- traefik.http.routers.whoami.rule=Path(`/whoami`)
- traefik.http.routers.whoami.priority=5
- traefik.http.services.whoami.loadbalancer.server.port=80
networks:
- lb_network
traefik:
image: traefik:v2.3.1
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
deploy:
mode: global
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
command:
- --providers.docker
- --providers.docker.constraints=Label(`traefik.constraint-label`, `traefik-public`)
- --providers.docker.exposedbydefault=false
- --providers.docker.swarmmode
- --entrypoints.http.address=:80
- --entrypoints.https.address=:443
#- --log.level=INFO
- --accesslog
- --log
- --api
networks:
- lb_network
portainer:
image: portainer/portainer-ce:2.0.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- lb_network
deploy:
mode: replicated
replicas: 1
labels:
- traefik.enable=true
- traefik.docker.network=lb_network
- traefik.constraint-label=traefik-public
- traefik.http.routers.portainer.entrypoints=http
- traefik.http.routers.portainer.rule=PathPrefix(`/`)
- traefik.http.routers.portainer.priority=1
- traefik.http.services.portainer.loadbalancer.server.port=9000
networks:
# Use the previously created public network "traefik-public", shared with other
# services that need to be publicly available via this Traefik
lb_network:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment