Use variables for router_name?

Hi,

Been digging on the internet for some time now but can't seem to find the answer to this question:

I want to be able to use ENV for router names, as I'm deploying several different instances doing the same thing, but with different routes. I'm currently testing on Traefik V3.0 (beta3). Basically;

      - "traefik.enable=true"
      - "traefik.http.routers.$ENV.rule=Host(`$DOMAIN`)"
      - "traefik.http.services.$ENV.loadbalancer.server.port=3000"
      - "traefik.http.routers.$ENV.entrypoints=websecure"
      - "traefik.http.routers.$ENV.tls.certresolver=leresolver"

DOMAIN is working fine, but I had no success with $ENV so far.

Thanks!

Traefik does not support templating everywhere. But Docker compose itself can do templating, maybe that helps. Not sure if it works for labels, though. See for example here.

services:
  web:
    image: some-image:1.0.0
    volumes:
      - ${DATA_PATH}:/data
    environment:
      - NODE_ENV=${NODE_ENV}

Thanks for the pointer, but as you can see in my first question:

$DOMAIN is working fine, but I had no success with $ENV so far.

So, my question is if it's possible at all to do labels? I tried but didn't succeed, but maybe I'm doing it the wrong way..?

Did you try ${ENV}?

Nope, but now I did, and those brackets seems to have made the difference!

Thanks again!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.