-
-
Save paulknulst/68e5e63badaa6a9ac80b4227ca07baee to your computer and use it in GitHub Desktop.
my first docker-compose for a traefik service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.3" | |
services: | |
traefik: | |
image: "traefik:v2.2.1" | |
container_name: traefik | |
hostname: traefik | |
command: | |
- --entrypoints.web.address=:80 | |
- --entrypoints.websecure.address=:443 | |
- --providers.docker | |
- --providers.docker.exposedByDefault=false | |
- --api | |
- --certificatesresolvers.le.acme.email=${TRAEFIK_SSLEMAIL?Variable not set} | |
- --certificatesresolvers.le.acme.storage=./acme.json | |
- --certificatesresolvers.le.acme.tlschallenge=true | |
ports: | |
- "80:80" | |
- "443:443" | |
volumes: | |
- "/var/run/docker.sock:/var/run/docker.sock:ro" | |
- "./acme.json:/acme.json" | |
labels: | |
- "traefik.enable=true" | |
# Dashboard | |
- "traefik.http.routers.traefik.rule=Host(`dashboard.${PRIMARY_DOMAIN}`)" | |
- "traefik.http.routers.traefik.service=api@internal" | |
- "traefik.http.routers.traefik.tls=true" | |
- "traefik.http.routers.traefik.tls.certresolver=le" | |
- "traefik.http.routers.traefik.entrypoints=websecure" | |
- "traefik.http.routers.traefik.middlewares=authtraefik" | |
- "traefik.http.middlewares.authtraefik.basicauth.users=devAdmin:$$2y$$05$$h9OxLeY20/5uiXjfPgdRxuFlrfqBf2QifYDgrwsR6rAEgX3/dpOGq" # user:devAdmin, password:devto | |
# global redirect to https | |
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)" | |
- "traefik.http.routers.http-catchall.entrypoints=web" | |
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https" | |
# middleware redirect | |
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" | |
restart: unless-stopped | |
networks: | |
- traefik-public | |
my-app: | |
image: containous/whoami:v1.3.0 | |
hostname: whoami | |
container_name: whoami | |
restart: unless-stopped | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.my-app.rule=Host(`whoami.${PRIMARY_DOMAIN}`)" | |
- "traefik.http.routers.my-app.middlewares=auth" | |
- "traefik.http.routers.my-app.entrypoints=websecure" | |
- "traefik.http.routers.my-app.tls=true" | |
- "traefik.http.routers.my-app.tls.certresolver=le" | |
- "traefik.http.middlewares.authtraefik.basicauth.users=devAdmin:$$2y$$05$$h9OxLeY20/5uiXjfPgdRxuFlrfqBf2QifYDgrwsR6rAEgX3/dpOGq" # user:devAdmin, password:devto | |
networks: | |
- traefik-public | |
networks: | |
traefik-public: | |
external: true |
Bit late but... line 55 there is a :
on the network traefik-public
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for pointing this out. I will adjust the Compose file and test it later.