services: traefik: image:traefik:v3.7# current stable v3 minor (3.7.x, Jul 2026) ports: -"80:80" -"443:443" environment: -TZ=Asia/Shanghai volumes: # /traefik.yml and /etc/traefik/traefik.yml are both available. -"./traefik.yml:/etc/traefik/traefik.yml" # dynamic-conf dir is self-defined -"./dynamic-conf:/etc/traefik/dynamic-conf" -"./certs:/certs" -"/var/run/docker.sock:/var/run/docker.sock:ro" networks: -traefik-net
For Windows: Edit C:\Windows\System32\drivers\etc\hosts
Add the following line:
1
127.0.0.1 traefik.x.internal
Generate Self-Signed Certificates
Choose one of the following options:
Option 1: Using mkcert (Recommended for Development)
mkcert can solve browser trust issues. Install mkcert, then run:
1 2 3 4 5 6
# directly gen certs at the current dir # mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1 # specify the cert output dir mkcert -key-file certs/key.pem -cert-file certs/cert.pem x.internal "*.x.internal" mkcert -install
# When using -x509, default_days in config will be ignored, it is a bug # using -days to workaround openssl req -x509 -new -nodes -days 365 \ -config ssl.cnf \ -keyout certs/key.pem \ -out certs/cert.pem
ssl.cnf like as follows:
Tips: DNS.1, DNS.2, IP.7, DNS.11, the numbers are only required to be unique, and can also be unordered.