defaultRule in docker provider raise error in fileProvider:

Hi,

I noticed that introducing defaultRule parameter in my configuration :

  docker:                                                                     
    exposedbydefault: true                                                    
    network: "traefik_net"                                                    
    defaultRule: Host(`{{ normalize .Name }}`)                               

Or even commented out :

  docker:                                                                     
    exposedbydefault: true                                                    
    network: "traefik_net"                                                    
    #defaultRule: Host(`{{ normalize .Name }}`)                               

Fails my Fileprovider :

providers:
  # Enable the file provider to define routers / middlewares / services in a file
  file:
    filename: dynamic_conf.yml
    directory: "/etc/traefik/"
  docker:
    exposedbydefault: true
    network: "traefik_net"
    #defaultRule: Host(`{{ normalize .Name }}`)

With this error :


time="2019-11-10T18:57:42Z" level=error msg="Error occurred during watcher callback: /etc/traefik/traefik.yml: template: dynamic_conf.yml:25:37: executing \"dynamic_conf.yml\" at <.Name>: can't evaluate field Name in type bool" providerName=file

Is this a bug ? Or I missed something ?

I don't think that what you are describing is really happening. I think what's really happening is that you've done a bunch of changes and one of them made your configuration to fail parsing, but you singled out one, unrelated change to describe above.

Please post your entire configuration, and do some more debugging by re-creating all your containers from scratch, or make sure that this is not a watcher problem. (It should not be, but it's good to have a reliable reproduction).

When you post your debug logs makes sure to include the static configuration dumped in the first few lines after traefik starts. That makes it possible to compare your posted config, with what traefik actually sees. Any discrepancies may indicated mistakes in the configuration.

Here the configuration (With the line commented out) :

╰─# cat traefik.yml
defaultEntryPoints: ["http", "https"]

log:
  level: "DEBUG"

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

api:
  dashboard: True
  insecure: False
  debug: True

providers:
  # Enable the file provider to define routers / middlewares / services in a file
  file:
    filename: dynamic_conf.yml
    directory: "/etc/traefik/"
  docker:
    exposedbydefault: true
    network: "traefik_net"
    #defaultRule: Host(`{{ normalize .Name }}`)

So now I restart Traefik container (with this configuration):

Debug Logs are :

time="2019-11-10T20:08:06Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.yml"
time="2019-11-10T20:08:06Z" level=info msg="Traefik version 2.0.4 built on 2019-10-28T20:23:57Z"
time="2019-11-10T20:08:06Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}},\"https\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"exposedByDefault\":true,\"network\":\"traefik_net\",\"swarmModeRefreshSeconds\":15000000000},\"file\":{\"directory\":\"/etc/traefik/\",\"watch\":true,\"filename\":\"dynamic_conf.yml\"}},\"api\":{\"dashboard\":true,\"debug\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"}}"
time="2019-11-10T20:08:06Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
time="2019-11-10T20:08:06Z" level=debug msg="No default certificate, generating one"
time="2019-11-10T20:08:06Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
time="2019-11-10T20:08:06Z" level=debug msg="Start TCP Server" entryPointName=http
time="2019-11-10T20:08:06Z" level=info msg="Starting provider *file.Provider {\"directory\":\"/etc/traefik/\",\"watch\":true,\"filename\":\"dynamic_conf.yml\"}"
time="2019-11-10T20:08:06Z" level=debug msg="Start TCP Server" entryPointName=https
time="2019-11-10T20:08:06Z" level=error msg="Cannot start the provider *file.Provider: /etc/traefik/traefik.yml: template: dynamic_conf.yml:25:37: executing \"dynamic_conf.yml\" at <.Name>: can't evaluate field Name in type bool"
time="2019-11-10T20:08:06Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"exposedByDefault\":true,\"network\":\"traefik_net\",\"swarmModeRefreshSeconds\":15000000000}"
time="2019-11-10T20:08:06Z" level=debug msg="Provider connection established with docker 19.03.4 (API 1.40)" providerName=docker
time="2019-11-10T20:08:06Z" level=warning msg="Could not find network named 'traefik_net' for container '/compose_files_portainer_1'! Maybe you're missing the project's prefix in the label? Defaulting to first available network." providerName=docker container=portainer-compose-files-531a6736d024a476a8ab23e3589881b8fa3078c786b1759d2106f79dc4c5012c serviceName=portainer-compose-files
time="2019-11-10T20:08:06Z" level=warning msg="Could not find network named 'traefik_net' for container '/ddclient'! Maybe you're missing the project's prefix in the label? Defaulting to first available network." providerName=docker container=ddclient-494287a96386ff69f81aa0327cd9c488f8ec3014d84e9f2930728b643395500a serviceName=ddclient
time="2019-11-10T20:08:06Z" level=error msg="port is missing" providerName=docker container=ddclient-494287a96386ff69f81aa0327cd9c488f8ec3014d84e9f2930728b643395500a
time="2019-11-10T20:08:06Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"portainer-compose-files\":{\"service\":\"portainer-compose-files\",\"rule\":\"Host(`portainer-compose-files`)\"},\"traefik\":{\"service\":\"traefik\",\"rule\":\"Host(`traefik`)\"},\"whoami\":{\"service\":\"whoami\",\"rule\":\"Host(`whoami.arthurgarnier.fr`)\"}},\"services\":{\"portainer-compose-files\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.18.0.2:8000\"}],\"passHostHeader\":true}},\"traefik\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.19.0.3:80\"}],\"passHostHeader\":true}},\"whoami\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.19.0.2:80\"}],\"passHostHeader\":true}}}},\"tcp\":{}}" providerName=docker
time="2019-11-10T20:08:06Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=whoami@docker
time="2019-11-10T20:08:06Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=portainer-compose-files@docker
time="2019-11-10T20:08:06Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=traefik@docker
time="2019-11-10T20:08:06Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining entryPointName=http routerName=whoami@docker serviceName=whoami
time="2019-11-10T20:08:06Z" level=debug msg="Creating load-balancer" serviceName=whoami entryPointName=http routerName=whoami@docker
time="2019-11-10T20:08:06Z" level=debug msg="Creating server 0 http://172.19.0.2:80" serverName=0 entryPointName=http routerName=whoami@docker serviceName=whoami
time="2019-11-10T20:08:06Z" level=debug msg="Added outgoing tracing middleware whoami" entryPointName=http routerName=whoami@docker middlewareName=tracing middlewareType=TracingForwarder
time="2019-11-10T20:08:06Z" level=debug msg="Creating middleware" routerName=portainer-compose-files@docker serviceName=portainer-compose-files middlewareName=pipelining middlewareType=Pipelining entryPointName=http
time="2019-11-10T20:08:06Z" level=debug msg="Creating load-balancer" serviceName=portainer-compose-files entryPointName=http routerName=portainer-compose-files@docker
time="2019-11-10T20:08:06Z" level=debug msg="Creating server 0 http://172.18.0.2:8000" routerName=portainer-compose-files@docker serviceName=portainer-compose-files entryPointName=http serverName=0
time="2019-11-10T20:08:06Z" level=debug msg="Added outgoing tracing middleware portainer-compose-files" routerName=portainer-compose-files@docker middlewareName=tracing middlewareType=TracingForwarder entryPointName=http
time="2019-11-10T20:08:06Z" level=debug msg="Creating middleware" middlewareType=Pipelining serviceName=traefik entryPointName=http routerName=traefik@docker middlewareName=pipelining
time="2019-11-10T20:08:06Z" level=debug msg="Creating load-balancer" entryPointName=http routerName=traefik@docker serviceName=traefik
time="2019-11-10T20:08:06Z" level=debug msg="Creating server 0 http://172.19.0.3:80" entryPointName=http routerName=traefik@docker serviceName=traefik serverName=0
time="2019-11-10T20:08:06Z" level=debug msg="Added outgoing tracing middleware traefik" middlewareName=tracing entryPointName=http routerName=traefik@docker middlewareType=TracingForwarder
time="2019-11-10T20:08:06Z" level=debug msg="Creating middleware" entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2019-11-10T20:08:06Z" level=debug msg="Creating middleware" middlewareName=traefik-internal-recovery middlewareType=Recovery entryPointName=https
time="2019-11-10T20:08:06Z" level=debug msg="No default certificate, generating one"

Now I just remove the line : #defaultRule: Host({{ normalize .Name }})

AND NOTHING ELSE. Then restarting container :

Here the logs :

time="2019-11-10T20:10:42Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.yml"
time="2019-11-10T20:10:42Z" level=info msg="Traefik version 2.0.4 built on 2019-10-28T20:23:57Z"
time="2019-11-10T20:10:42Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}},\"https\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"exposedByDefault\":true,\"network\":\"traefik_net\",\"swarmModeRefreshSeconds\":15000000000},\"file\":{\"directory\":\"/etc/traefik/\",\"watch\":true,\"filename\":\"dynamic_conf.yml\"}},\"api\":{\"dashboard\":true,\"debug\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"}}"
time="2019-11-10T20:10:42Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
time="2019-11-10T20:10:42Z" level=debug msg="No default certificate, generating one"
time="2019-11-10T20:10:42Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
time="2019-11-10T20:10:42Z" level=debug msg="Start TCP Server" entryPointName=http
time="2019-11-10T20:10:42Z" level=info msg="Starting provider *file.Provider {\"directory\":\"/etc/traefik/\",\"watch\":true,\"filename\":\"dynamic_conf.yml\"}"
time="2019-11-10T20:10:42Z" level=debug msg="Start TCP Server" entryPointName=https
time="2019-11-10T20:10:42Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"exposedByDefault\":true,\"network\":\"traefik_net\",\"swarmModeRefreshSeconds\":15000000000}"
time="2019-11-10T20:10:42Z" level=debug msg="Configuration received from provider file: {\"http\":{\"routers\":{\"api\":{\"middlewares\":[\"dash-auth\"],\"service\":\"api@internal\",\"rule\":\"Host(`traefik.thanos.local`)\"}},\"middlewares\":{\"dash-auth\":{\"basicAuth\":{\"users\":[\"admin:$apr1$mOYHxwBa$7KV2biA89CxJNrW8ehQ.b/\"]}},\"https-only\":{\"redirectScheme\":{\"scheme\":\"https\"}}}},\"tcp\":{},\"tls\":{}}" providerName=file
time="2019-11-10T20:10:42Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=api@file
time="2019-11-10T20:10:42Z" level=debug msg="Added outgoing tracing middleware api@internal" entryPointName=http routerName=api@file middlewareName=tracing middlewareType=TracingForwarder
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" middlewareName=dash-auth@file middlewareType=BasicAuth entryPointName=http routerName=api@file
time="2019-11-10T20:10:42Z" level=debug msg="Adding tracing to middleware" routerName=api@file entryPointName=http middlewareName=dash-auth@file
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" entryPointName=https middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2019-11-10T20:10:42Z" level=debug msg="No default certificate, generating one"
time="2019-11-10T20:10:42Z" level=debug msg="Provider connection established with docker 19.03.4 (API 1.40)" providerName=docker
time="2019-11-10T20:10:42Z" level=warning msg="Could not find network named 'traefik_net' for container '/compose_files_portainer_1'! Maybe you're missing the project's prefix in the label? Defaulting to first available network." providerName=docker serviceName=portainer-compose-files container=portainer-compose-files-531a6736d024a476a8ab23e3589881b8fa3078c786b1759d2106f79dc4c5012c
time="2019-11-10T20:10:42Z" level=warning msg="Could not find network named 'traefik_net' for container '/ddclient'! Maybe you're missing the project's prefix in the label? Defaulting to first available network." providerName=docker container=ddclient-494287a96386ff69f81aa0327cd9c488f8ec3014d84e9f2930728b643395500a serviceName=ddclient
time="2019-11-10T20:10:42Z" level=error msg="port is missing" container=ddclient-494287a96386ff69f81aa0327cd9c488f8ec3014d84e9f2930728b643395500a providerName=docker
time="2019-11-10T20:10:42Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"portainer-compose-files\":{\"service\":\"portainer-compose-files\",\"rule\":\"Host(`portainer-compose-files`)\"},\"traefik\":{\"service\":\"traefik\",\"rule\":\"Host(`traefik`)\"},\"whoami\":{\"service\":\"whoami\",\"rule\":\"Host(`whoami.arthurgarnier.fr`)\"}},\"services\":{\"portainer-compose-files\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.18.0.2:8000\"}],\"passHostHeader\":true}},\"traefik\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.19.0.3:80\"}],\"passHostHeader\":true}},\"whoami\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.19.0.2:80\"}],\"passHostHeader\":true}}}},\"tcp\":{}}" providerName=docker
time="2019-11-10T20:10:42Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=whoami@docker
time="2019-11-10T20:10:42Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=portainer-compose-files@docker
time="2019-11-10T20:10:42Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=traefik@docker
time="2019-11-10T20:10:42Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http https]" routerName=api@file
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" entryPointName=https routerName=whoami@docker serviceName=whoami middlewareName=pipelining middlewareType=Pipelining
time="2019-11-10T20:10:42Z" level=debug msg="Creating load-balancer" routerName=whoami@docker serviceName=whoami entryPointName=https
time="2019-11-10T20:10:42Z" level=debug msg="Creating server 0 http://172.19.0.2:80" serverName=0 entryPointName=https routerName=whoami@docker serviceName=whoami
time="2019-11-10T20:10:42Z" level=debug msg="Added outgoing tracing middleware whoami" entryPointName=https routerName=whoami@docker middlewareName=tracing middlewareType=TracingForwarder
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" serviceName=portainer-compose-files middlewareName=pipelining middlewareType=Pipelining entryPointName=https routerName=portainer-compose-files@docker
time="2019-11-10T20:10:42Z" level=debug msg="Creating load-balancer" entryPointName=https routerName=portainer-compose-files@docker serviceName=portainer-compose-files
time="2019-11-10T20:10:42Z" level=debug msg="Creating server 0 http://172.18.0.2:8000" entryPointName=https routerName=portainer-compose-files@docker serviceName=portainer-compose-files serverName=0
time="2019-11-10T20:10:42Z" level=debug msg="Added outgoing tracing middleware portainer-compose-files" routerName=portainer-compose-files@docker middlewareName=tracing middlewareType=TracingForwarder entryPointName=https
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining entryPointName=https routerName=traefik@docker serviceName=traefik
time="2019-11-10T20:10:42Z" level=debug msg="Creating load-balancer" entryPointName=https routerName=traefik@docker serviceName=traefik
time="2019-11-10T20:10:42Z" level=debug msg="Creating server 0 http://172.19.0.3:80" serverName=0 entryPointName=https routerName=traefik@docker serviceName=traefik
time="2019-11-10T20:10:42Z" level=debug msg="Added outgoing tracing middleware traefik" entryPointName=https routerName=traefik@docker middlewareName=tracing middlewareType=TracingForwarder
time="2019-11-10T20:10:42Z" level=debug msg="Added outgoing tracing middleware api@internal" middlewareName=tracing middlewareType=TracingForwarder entryPointName=https routerName=api@file
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" entryPointName=https routerName=api@file middlewareName=dash-auth@file middlewareType=BasicAuth
time="2019-11-10T20:10:42Z" level=debug msg="Adding tracing to middleware" middlewareName=dash-auth@file entryPointName=https routerName=api@file
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" entryPointName=https middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2019-11-10T20:10:42Z" level=debug msg="Creating middleware" middlewareType=Recovery middlewareName=traefik-internal-recovery entryPointName=http
time="2019-11-10T20:10:42Z" level=debug msg="No default certificate, generating one"
time="2019-11-10T20:10:45Z" level=debug msg="Authentication succeeded" middlewareName=dash-auth@file middlewareType=BasicAuth

Note that recreating or restarting the container give the same result...

Where is the rest of your configuration?

As the message say: the error is in the dynamic_conf.yml file.

Also some note about your static configuration:

# `defaultEntryPoints` is a v1 configuration, not supported in v2
# defaultEntryPoints: ["http", "https"] 

log:
  level: "DEBUG"

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

api:
  dashboard: true
  insecure: false
  # the `debug` option is for pprof https://docs.traefik.io/operations/api/#debug, so you don't need that
  # debug: true

providers:
  file:
    # you cannot use both (`filename` and `directory`), you need to choose only one.
    filename: dynamic_conf.yml 
    # directory: /etc/traefik/
  docker:
    # YAML is case sensitive
    # exposedbydefault: true
    exposedByDefault: true
    network: traefik_net
    #defaultRule: Host(`{{ normalize .Name }}.localhost`)

as @zespri says, could you provide more information:

  • docker-compose file
  • the dynamic_conf.yml file

Also could you explain what you are trying to do?

The below is what is usually useful for diagnosing, apologies for partial repetitions, but I did not figure out how to keep it coherent without:

  • Provide your traefik static configuration file if you are using it. It is usually, but not always called traefik.toml.
  • If you are not using Docker/Kubernetes/Etc, provide the command line you are using to start traefik.
  • If you are using docker, but not docker-compose provide the command line that you are using to start traefik container.
  • If you are using docker-compose, provide your docker-compose file usually it's called docker-compose.yaml or docker-compose.yml
  • If you are using docker swarm provide your compose file that you are using with docker stack deploy
  • If you are using Kubernetes, please provide manifests for all relevant objects. There is a good working example here. Often kubernetes configuration do not work not because of a mistake in an IngressRoute but in the way Kubernetes is deployed. So make sure to include all kubernetes objects that are relevant. Here is a short checklist, note that it is not exhaustive, and may vary depending on your deployment. Add anything that is not mentioned here but relevant too. Note that not all of those item may always be present in your installation
    • Traefik Deployment/DaemonSet object
    • Traefik Service(s)/Ingress(es)
    • Traefik CRDs
    • Traefik security objects such as CluserRole(s), ClusterRoleBinding(s) and ServiceAccount(s)
    • Your application Deployment(s) / Service(s) / Ingress(es) / IngressRoute(s)
  • If your configuration uses any other files, in particular, if you are using file provider to load additional configuration, please provide those files as well.
  • Please enable debug log and provide relevant log entries. Note that the complete debug log can be overwhelming to post (use gist or pastebin), yet it is important that relevant parts of it are included. Here are the most useful parts of the log to provide:
    • Traefik dumps its static configuration on strart up, and dynamic configuration whenever it's received from a proivder to the log. Dynamic configuration is dumped repeatedly whenever it is received from each of the providers you are using. It is extremely useful for diagnostics, to provide this, as we can compare the config (expected) to the dump (what traefik actually sees), any descripansice help identify configuration issues
    • Any records that have word "error" (any case) in it, and a sufficently large portion of the log immediately preceeding those lines

Hi,

Sorry for the late answer. I delayed a bit my project, changed some things and now I'm not able to reproduce anymore...

Thanks for your help around this issue, it helped me to make a cleaner configuration !

Regards,

Hi Everyone,

Iam able to reproduce this one.

this is my configuration:

[global]
  checkNewVersion = true
  sendAnonymousUsage = false
[entryPoints]
  [entryPoints.web]
    address = ":80"
  [entryPoints.websecure]
    address = ":443"
[log]
  level = "DEBUG"
[api]
  dashboard = true
  debug = true
[ping]
[providers]
[providers.docker]
  network = "traefik"
  exposedByDefault = false
[providers.file]
  filename = "/etc/traefik/traefik.toml"
  watch = true
[http.middlewares.auth.basicAuth]
  users = [
    "admin:$apr1$H6ussssW$IgYLP2ewrrSuBkTrqE8wj/",
  ]

i start the container using the following command:

docker run --rm --name traefik -it -p 80:80 -p 443:443 -p 8080:8080 -v /home/bob/traefik/traefik.toml:/etc/traefik//traefik.toml -v /var/run/docker.sock:/var/run/docker.sock:ro traefik:v2.2.0 --global.checkNewVersion=true --entryPoints.http.address=:80 --entryPoints.https.address=:443 --log=true --log.level=DEBUG --accessLog=true --providers.docker=true --providers.docker.swarmMode=false --label=traefik.enable=true --label="traefik.http.routers.http-catchall.entrypoints=http" --lable="traefik.http.routers.http-catchall.rule=HostRegexp(\`{host:.+}\`)" --label="traefik.http.routers.http-catchall.middlewares=redirect-to-https" --label="traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

and I get the following error while starting and a 404 for the dashboard

bob@hanibal:~/traefik$ docker run --rm --name traefik -it -p 80:80 -p 443:443 -p 8080:8080 -v /home/bob/traefik/traefik.toml:/etc/traefik/traefik.toml 
-v /var/run/docker.sock:/var/run/docker.sock:ro traefik:v2.2.0 
--global.checkNewVersion=true 
--entryPoints.http.address=:80 
--entryPoints.https.address=:443 
--log=true 
--log.level=DEBUG 
--accessLog=true 
--providers.docker=true 
--providers.docker.swarmMode=false 
--label=traefik.enable=true 
--label="traefik.http.routers.http-catchall.entrypoints=http" 
--lable="traefik.http.routers.http-catchall.rule=HostRegexp(\`{host:.+}\`)" 
--label="traefik.http.routers.http-catchall.middlewares=redirect-to-https" 
--label="traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https

INFO[0000] Configuration loaded from file: /etc/traefik/traefik.toml
INFO[2020-04-27T10:20:04Z] Traefik version 2.2.0 built on 2020-03-25T17:32:57Z
DEBU[2020-04-27T10:20:04Z] Static configuration loaded {"global":{"checkNewVersion":true},"serversTransport":{"maxIdleConnsPerHost":200},"entryPoints":{"traefik":{"address":":8080","transport":{"lifeCycle":{"graceTimeOut":10000000000},"respondingTimeouts":{"idleTimeout":180000000000}},"forwardedHeaders":{},"http":{}},"web":{"address":":80","transport":{"lifeCycle":{"graceTimeOut":10000000000},"respondingTimeouts":{"idleTimeout":180000000000}},"forwardedHeaders":{},"http":{}},"websecure":{"address":":443","transport":{"lifeCycle":{"graceTimeOut":10000000000},"respondingTimeouts":{"idleTimeout":180000000000}},"forwardedHeaders":{},"http":{}}},"providers":{"providersThrottleDuration":2000000000,"docker":{"watch":true,"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host(`{{ normalize .Name }}`)","network":"traefik","swarmModeRefreshSeconds":15000000000},"file":{"watch":true,"filename":"/etc/traefik/traefik.toml"}},"api":{"dashboard":true,"debug":true},"ping":{"entryPoint":"traefik"},"log":{"level":"DEBUG","format":"common"}}
INFO[2020-04-27T10:20:04Z]
Stats collection is disabled.
Help us improve Traefik by turning this feature on :)
More details on: https://docs.traefik.io/contributing/data-collection/
INFO[2020-04-27T10:20:04Z] Starting provider aggregator.ProviderAggregator {}
DEBU[2020-04-27T10:20:04Z] Start TCP Server                              entryPointName=websecure
INFO[2020-04-27T10:20:04Z] Starting provider *file.Provider {"watch":true,"filename":"/etc/traefik/traefik.toml"}
DEBU[2020-04-27T10:20:04Z] Start TCP Server                              entryPointName=traefik
DEBU[2020-04-27T10:20:04Z] Start TCP Server                              entryPointName=web
ERRO[2020-04-27T10:20:04Z] Cannot start the provider *file.Provider: template: /etc/traefik/traefik.toml:145:33: executing "/etc/traefik/traefik.toml" at <.Name>: can't evaluate field Name in type bool
INFO[2020-04-27T10:20:04Z] Starting provider *traefik.Provider {}
INFO[2020-04-27T10:20:04Z] Starting provider *docker.Provider {"watch":true,"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host(`{{ normalize .Name }}`)","network":"traefik","swarmModeRefreshSeconds":15000000000}
DEBU[2020-04-27T10:20:04Z] Configuration received from provider internal: {"http":{"routers":{"ping":{"entryPoints":["traefik"],"service":"ping@internal","rule":"PathPrefix(`/ping`)","priority":2147483647}},"services":{"api":{},"dashboard":{},"noop":{},"ping":{}}},"tcp":{},"tls":{}}  providerName=internal
DEBU[2020-04-27T10:20:04Z] Added outgoing tracing middleware ping@internal  routerName=ping@internal middlewareName=tracing middlewareType=TracingForwarder entryPointName=traefik
DEBU[2020-04-27T10:20:04Z] Creating middleware                           entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
DEBU[2020-04-27T10:20:04Z] No default certificate, generating one
DEBU[2020-04-27T10:20:04Z] Provider connection established with docker 19.03.8 (API 1.40)  providerName=docker
DEBU[2020-04-27T10:20:04Z] Configuration received from provider docker: {"http":{},"tcp":{},"udp":{}}  providerName=docker
DEBU[2020-04-27T10:20:04Z] Provider event received {Status:start ID:5a922a68668e10e2860fd44edaba5c20a0b795343e77c984bf64191d92f153ad From:traefik:v2.2.0 Type:container Action:start Actor:{ID:5a922a68668e10e2860fd44edaba5c20a0b795343e77c984bf64191d92f153ad Attributes:map[image:traefik:v2.2.0 name:traefik org.opencontainers.image.description:A modern reverse-proxy org.opencontainers.image.documentation:https://docs.traefik.io org.opencontainers.image.title:Traefik org.opencontainers.image.url:https://traefik.io org.opencontainers.image.vendor:Containous org.opencontainers.image.version:v2.2.0]} Scope:local Time:1587982804 TimeNano:1587982804930374024}  providerName=docker
DEBU[2020-04-27T10:20:04Z] Filtering disabled container                  container=traefik-5a922a68668e10e2860fd44edaba5c20a0b795343e77c984bf64191d92f153ad providerName=docker
DEBU[2020-04-27T10:20:04Z] Configuration received from provider docker: {"http":{},"tcp":{},"udp":{}}  providerName=docker
INFO[2020-04-27T10:20:04Z] Skipping same configuration                   providerName=docker
DEBU[2020-04-27T10:20:05Z] Added outgoing tracing middleware ping@internal  middlewareName=tracing entryPointName=traefik routerName=ping@internal middlewareType=TracingForwarder
DEBU[2020-04-27T10:20:05Z] Creating middleware                           entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
DEBU[2020-04-27T10:20:05Z] No default certificate, generating one

I recommend to not use the same file for the static and the dynamic configuration.

also:

There are three different, mutually exclusive (e.g. you can use only one at the same time), ways to define static configuration options in Traefik:

https://docs.traefik.io/v2.2/getting-started/configuration-overview/#the-static-configuration

So you cannot use CLI flags and file at the same time for the static configuration.

1 Like

Hi @Idez,

thanks for the valid hint mixing command line and file direction is a no go! the confusion comes from the fact that i was not able to correctly escape labels and ends up with:

bob@hanibal:~/traefik$ docker run --rm --name traefik -it -p 80:80 -p 443:443 -p 8080:8080 
 -v /var/run/docker.sock:/var/run/docker.sock:ro traefik:v2.2.0 
 --global.checkNewVersion=true 
 --log=true --log.level=DEBUG 
 --accessLog=true 
 --providers.docker=true 
 --providers.docker.swarmMode=false 
 --entryPoints.http.address=:80 
 --entryPoints.https.address=:443 
 --label="traefik.enable=true"
 --label="traefik.http.routers.http-catchall.entrypoints=http" 
 --lable="traefik.http.routers.http-catchall.rule=HostRegexp(\`{host:.+}\`)" 
 --label="traefik.http.routers.http-catchall.middlewares=redirect-to-https" 
 --label="traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

2020/04/27 11:27:20 command traefik error: failed to decode configuration from flags: field not found, node: label
bob@hanibal:~/traefik$

so I switched to file providers hoping to identify the problem with CLI later

Thanks

You have to set the --label flags at the right place and beware of typos (lable -> `label)

docker run --rm --name traefik  -it \
 -p 80:80 -p 443:443 -p 8080:8080 \
 --label="traefik.enable=true" \
 --label="traefik.http.routers.http-catchall.entrypoints=http"  \
 --label="traefik.http.routers.http-catchall.rule=HostRegexp(\`{host:.+}\`)"  \
 --label="traefik.http.routers.http-catchall.middlewares=redirect-to-https"  \
 --label="traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" \
 -v /var/run/docker.sock:/var/run/docker.sock:ro \
 traefik:v2.2.0 \
 --global.checkNewVersion=true \
 --log=true --log.level=DEBUG \
 --accessLog=true \
 --providers.docker=true \
 --providers.docker.swarmMode=false \
 --entryPoints.http.address=:80 \
 --entryPoints.https.address=:443
1 Like

Thanks you @Idez
the typo is well spotted and the order of labels too!!