Skip to content

Instantly share code, notes, and snippets.

@thibaut-d
Last active July 1, 2021 22:59
Show Gist options
  • Save thibaut-d/b483b5abf9a96cd8bad1447d22dd5e8d to your computer and use it in GitHub Desktop.
Save thibaut-d/b483b5abf9a96cd8bad1447d22dd5e8d to your computer and use it in GitHub Desktop.
docker-compose.yml for Traefik
version: "3.3"
networks:
# Allow the use of traefik in other docker-compose.yml files
traefik:
external: true
services:
traefik:
image: "traefik:v2.2"
container_name: "traefik"
logging:
options:
max-size: "10m"
max-file: "3"
command:
# Only for development environment
- "--log.level=DEBUG"
- "--api.insecure=true"
# Get Docker as the provider
- "--providers.docker=true"
# Avoid that all containers are exposed
- "--providers.docker.exposedbydefault=false"
# Settle the ports for the entry points
- "--entrypoints.web.address=:80"
- "--entrypoints.web-secure.address=:443"
# Settle the autentification method to http challenge
- "--certificatesresolvers.myhttpchallenge.acme.httpchallenge=true"
- "--certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web"
# Uncomment this to get a fake certificate when testing
#- "--certificatesresolvers.myhttpchallenge.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
# Settle letsencrypt as the certificate provider
- "--certificatesresolvers.myhttpchallenge.acme.email=me@mail.com"
- "--certificatesresolvers.myhttpchallenge.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080"
networks:
- "traefik"
volumes:
# Store certificates in ./letsencrypt/acme.json
- "./letsencrypt:/letsencrypt"
# Connect to Doker socket
- "/var/run/docker.sock:/var/run/docker.sock:ro"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment