basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    traefik.yml doesn’t substitute variables

    ${…} is substituted by compose, and only in the compose file. Traefik reads traefik.yml itself, so with email: ${EMAIL_FOR_SSL} the address becomes the string ${EMAIL_FOR_SSL} itself — write explicit values in the static config.

    Who substitutes what

    Compose substitutes ${…} from .env into the compose file: labels, environment:, command:. Files the service reads on its own are left alone — traefik.yml reaches the container as is.

    So traefik.yml gets explicit values:

    certificatesResolvers:
      cloudflare:
        acme:
          email: [email protected]          # not ${EMAIL_FOR_SSL}

    Pass what you’d like to take from .env as the container’s environment variables — that’s how Traefik gets the DNS provider token: CF_DNS_API_TOKEN_FILE: /run/secrets/cf_api_token (Secrets in Docker stacks). Or move the static config entirely into command: arguments — compose substitutes ${…} there. But Traefik won’t read a file and arguments together: it has a single source of static config. Once it finds traefik.yml, it silently skips the command: arguments except --configFile.

    What happens when the ACME email becomes the string ${…}, and how to change it — Traefik and Let’s Encrypt.