Hello,
I am quite new to Traefik, and I am stuck at the moment with a problem I hope somebody here could help me with.
In my docker-compose file, I want to hide some of my variables with help of environment variables. In the same folder as my docker-compose file, I have a file called "traefik.env" with two key-value pairs.
"TRAEFIK_URL=traefik.localhost" and "LOG_LEVEL=DEBUG". In my compose file, I reference my env. file with the "env_file:" docker tag. The issue I'm having is that the variables are not read by docker or traefik. This is the warning I get: "WARN[0000] The "LOG_LEVEL" variable is not set. Defaulting to a blank string. "
What do I do wrong in my setup? Any other suggestions regarding my setup is appreciated. Thanks in advance for your help.
my docker-compose file
version: '3.9'
services:
traefik:
image: traefik:v3.0
container_name: traefik
env_file:
- ./.traefik.env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
# Traefik API
- TRAEFIK_API=true # enables the Traefik API. True by default
- TRAEFIK_API_INSECURE=true # allow access to the Traefik API over an insecure connection (HTTP).
- TRAEFIK_API_DASHBOARD=true # enables the Traefik dashboard. True by default.
# Logging configuration
- TRAEFIK_LOG_LEVEL=${LOG_LEVEL} # sets the log level (DEBUG, INFO, WARN, ERROR, FATAL, PANIC). DEBUG by default
- TRAEFIK_ACCESSLOG_FILTERS_STATUSCODES=400-499,500-599 # filters access logs to only include 400 and 500 level errors
# Provider configuration
- TRAEFIK_PROVIDERS_DOCKER=true # enables the Docker provider
- TRAEFIK_PROVIDERS_DOCKER_EXPOSEDBYDEFAULT=false # prevents Traefik from creating routes for containers that don't have a traefik.enable=true label
- TRAEFIK_PROVIDERS_DOCKER_WATCH=true # tells Traefik to listen to Docker events
# Entrypoints configuration
- TRAEFIK_ENTRYPOINTS_WEB_ADDRESS=:80 # sets the port for HTTP
- TRAEFIK_ENTRYPOINTS_WEBSECURE_ADDRESS=:443 # sets the port for HTTPS
ports:
- "80:80"
- "443:443"
labels:
# Traefik configuration
- "traefik.enable=true" # enables Traefik for this container
# Routers configuration
- "traefik.http.routers.traefik.rule=Host(`${TRAEFIK_URL}`)" # sets the hostname for the Traefik dashboard route
- "traefik.http.routers.traefik.entrypoints=web" # sets the entrypoint for the Traefik dashboard route
- "traefik.http.routers.traefik.service=api@internal" # ensures that the Traefik dashboard route is linked to the internal Traefik API service
- "traefik.http.routers.traefik.middlewares=auth" # applies the auth middleware to the Traefik dashboard route
# Services configuration
- "traefik.http.services.traefik.loadbalancer.server.port=8080" # sets the port for the Traefik dashboard service
My env file
TRAEFIK_URL=traefik.localhost
LOG_LEVEL=DEBUG