Skip to content

Instantly share code, notes, and snippets.

@vladbabii
Forked from alecs/portainer-only.yml
Created September 28, 2022 12:00
Show Gist options
  • Save vladbabii/e4119d10a733bebd34be6faba2ff2cd2 to your computer and use it in GitHub Desktop.
Save vladbabii/e4119d10a733bebd34be6faba2ff2cd2 to your computer and use it in GitHub Desktop.
traefik v28 + portainer 2.15 docker-compose
#
# mkdir -p /shared/portainer/data/
# docker-compose -f portainer-only.yml -p portainer up -d
#
version: '3.7'
services:
portainer:
image: portainer/portainer-ce:latest
container_name: 'portainer'
restart: always
security_opt:
- no-new-privileges:true
environment:
HOSTNAME: portainer
ports:
- target: 9000
published: 9000
protocol: tcp
mode: host
volumes:
- /shared/portainer/data/:/data
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.services.portainer.loadbalancer.server.port=9000"
- "traefik.http.routers.portainer.rule=Host(`portainer.domain.com`)"
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.service=portainer"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.tls.certresolver=letsencrypt"
networks:
traefik:
external: true
#
# docker network create -d bridge --gateway 172.21.22.1 --subnet 172.21.22.0/24 traefik
# mkdir -p /shared/traefik/certs /shared/traefik/acme2 /shared/traefik/logs
# docker-compose -f traefik-stack2x.yml -p traefik up -d
#
version: '3.7'
services:
traefik:
image: traefik:2.8
hostname: traefik
environment:
HOSTNAME: traefik
container_name: traefik
restart: always
command:
- "--api.insecure=true"
- "--api.dashboard=true"
- "--log.level=DEBUG"
- "--providers.docker=true"
- "--accessLog.filePath=/logs/access.log"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.swarmMode=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--global.sendAnonymousUsage=false"
- "--certificatesResolvers.letsencrypt.acme.httpchallenge=true"
- "--certificatesResolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
- "[email protected]"
- "--certificatesResolvers.letsencrypt.acme.storage=/acme2/acme.json"
ports:
- target: 80
published: 80
protocol: tcp
mode: host
- target: 443
published: 443
protocol: tcp
mode: host
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /shared/traefik/acme2:/acme2
- /shared/traefik/certs:/certs
- /shared/traefik/logs:/logs
networks:
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.dash.service=api@internal"
- "traefik.http.routers.dash.rule=Host(`traefik.domain.com`)"
- "traefik.http.routers.dash.entrypoints=websecure"
- "traefik.http.routers.dash.middlewares=traefik-auth"
- "traefik.http.routers.dash.tls.certresolver=letsencrypt"
- "traefik.http.routers.dash.tls=true"
- "traefik.http.middlewares.traefik-auth.basicauth.users=admin:apr hash here escape $ with $ ie $$"
networks:
traefik:
external: true
attachable: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment