When you specify docker.domain=dev.domain.tld in the TOML and create a Docker Swarm service/stack the default frontend rule will be stackName-serviceName.dev.domain.tld, which is really ugly when you have a single service per stack file.
How to change this? I could specify a custom Host or HostRegexp frontend rule, something like traefik.frontend.rule=HostRegexp:customName.{subdomain:(dev|staging|prod)}.domain.tld but it's really hacky/messy and you're stuck with these 3 environments. What if I add a new VPC for our release/pre-prod environment?
I'm using Terraform to span up a Docker Swarm for 3 different Terraform workspaces / VPCs (dev, staging, production) and using Træfik on each of them....... The traefik.toml is set up on the server initially when the instance is provisioned and the docker.domain is specified in it, based on my DNS zone Terraform resource and I keep my Docker stack/compose files seperate without specifying domain in each of them (because it varies between environments). Same Docker stack/compose file, different environments (VPC / DNS zones).
This would be really beneficial for those who are aiming at infrastructure-as-code with Terraform and trying to seperate domain/DNS/zones from frontend rules and want to keep their Docker stack/compose files "stateless" and not coupled to the environment/domain/DNS zone.
Let's say I want to use the same Docker stack file for 3 different DNS zones and 3 different Træfik instances... dev.domain.tld, staging.domain.tld, prod.domain.tld
I would like to specify myservice as a frontend/subdomain rule and it would work for all 3 different zones (based on docker.domain specified in the traefik.toml on the server), so the same Docker stack/compose file with myservice frontend rule in the Docker stack/compose file, would work for myservice.dev.domain.tld on Træfik instance on dev environment, myservice.staging.domain.tld on Træfik instance on staging environment and myservice.prod.domain.tld on Træfik instance on production environment.
I suggest to allow people to change the name of the stack/service via Træfik frontend label (traefik.name=someCustomName), so it would not become stackName-serviceName but instead someCustomName and that would generate a default frontend rule someCustomName.domain.tld.
Or to create a new variable ${domain} you could use in Docker service/container Træfik labels, so you could set docker.domain=dev.domain.tld (generated via TOML template file in Terraform) and then in stack file, use traefik.frontend.rule=Host:customName.${domain} and that would be translated to Host:customName.dev.domain.tld or whatever domain is set in the TOML. Then people could be in same control, without having to couple the domain to the Docker stack/compose file.
Do you want to request a feature or report a bug?
feature
What is your environment & configuration (arguments, toml, provider, platform, ...)?
Feature request
When you specify
docker.domain=dev.domain.tld
in the TOML and create a Docker Swarm service/stack the default frontend rule will bestackName-serviceName.dev.domain.tld
, which is really ugly when you have a single service per stack file.How to change this? I could specify a custom
Host
orHostRegexp
frontend rule, something liketraefik.frontend.rule=HostRegexp:customName.{subdomain:(dev|staging|prod)}.domain.tld
but it's really hacky/messy and you're stuck with these 3 environments. What if I add a new VPC for our release/pre-prod environment?I'm using Terraform to span up a Docker Swarm for 3 different Terraform workspaces / VPCs (dev, staging, production) and using Træfik on each of them....... The
traefik.toml
is set up on the server initially when the instance is provisioned and thedocker.domain
is specified in it, based on myDNS zone
Terraform resource and I keep my Docker stack/compose files seperate without specifying domain in each of them (because it varies between environments). Same Docker stack/compose file, different environments (VPC / DNS zones).This would be really beneficial for those who are aiming at infrastructure-as-code with Terraform and trying to seperate domain/DNS/zones from frontend rules and want to keep their Docker stack/compose files "stateless" and not coupled to the environment/domain/DNS zone.
Let's say I want to use the same Docker stack file for 3 different DNS zones and 3 different Træfik instances...
dev.domain.tld
,staging.domain.tld
,prod.domain.tld
I would like to specifymyservice
as a frontend/subdomain rule and it would work for all 3 different zones (based ondocker.domain
specified in thetraefik.toml
on the server), so the same Docker stack/compose file withmyservice
frontend rule in the Docker stack/compose file, would work formyservice.dev.domain.tld
on Træfik instance on dev environment,myservice.staging.domain.tld
on Træfik instance on staging environment andmyservice.prod.domain.tld
on Træfik instance on production environment.I suggest to allow people to change the name of the stack/service via Træfik frontend label (
traefik.name=someCustomName
), so it would not becomestackName-serviceName
but insteadsomeCustomName
and that would generate a default frontend rulesomeCustomName.domain.tld
. Or to create a new variable${domain}
you could use in Docker service/container Træfik labels, so you could setdocker.domain=dev.domain.tld
(generated via TOML template file in Terraform) and then in stack file, usetraefik.frontend.rule=Host:customName.${domain}
and that would be translated toHost:customName.dev.domain.tld
or whatever domain is set in the TOML. Then people could be in same control, without having to couple the domain to the Docker stack/compose file.