Skip to content

Instantly share code, notes, and snippets.

@piihuynh
Last active November 25, 2021 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piihuynh/7823e6044c1dee02d35452a252cd9d23 to your computer and use it in GitHub Desktop.
Save piihuynh/7823e6044c1dee02d35452a252cd9d23 to your computer and use it in GitHub Desktop.
Portainer-CE swarm mode with Traefik
version: '3.2'
services:
agent:
image: portainer/agent:2.9.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
environment:
AGENT_CLUSTER_ADDR: tasks.agent
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce:2.9.2
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9443:9443"
- "9000:9000"
- "8000:8000"
volumes:
- portainer-data:/data
networks:
- agent_network
- traefik-public
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
- node.labels.portainer.portainer-data == true
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.portainer-http.rule=Host(`${PORTAINER_DOMAIN?Variable not set}`)
- traefik.http.routers.portainer-http.entrypoints=http
- traefik.http.routers.portainer-http.middlewares=https-redirect
- traefik.http.routers.portainer-https.rule=Host(`${PORTAINER_DOMAIN?Variable not set}`)
- traefik.http.routers.portainer-https.entrypoints=https
- traefik.http.routers.portainer-https.tls=true
- traefik.http.routers.portainer-https.tls.certresolver=le
- traefik.http.services.portainer.loadbalancer.server.port=9000
networks:
agent_network:
driver: overlay
attachable: true
traefik-public:
external: true
volumes:
portainer-data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment