Use environment variables for router rules?

Hello,

this is my first post so please apologize if I'm doing something wrong.

I'm using docker-image of Traefik 2.0. I know that I can use labels for router rules, e.g. in CLI

--providers.docker.defaultrule=Host({{ index .Labels \"my_label\" }})

Unfortunately, this syntax doesn't seem to be documented anywhere (if it is, it would be kind to give a link). My question is whether I can use an environment variable instead of a label instead.

I have already tried "index .Environment" which doesn't work.

Thanks for any help :slight_smile:

Hello,

Some syntax references:

Both "documentations" don't really help, as none of them explains e.g. what the common example "Host({{ normalize .Name }})" does (especially the "normalize"). Also I miss a list of identifiers -- ".Name" and ".Labels" seem to be two of them, but where's a complete reference?

Traefik provide only 2 variables: .Name and .Labels

normalize is a function that normalize a string by replacing all special characters by -

index: it's a way to browse a map https://golang.org/pkg/text/template/#hdr-Functions

{{ index <map> <key> }}

For env vars:

--providers.docker.defaultrule=Host(`{{ env \"MY_ENV_VAR\" `}})