Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove docker-compose stack name from Traefik V2 defaultRule

In Traefik V2 the .Name attribute in the defaultRule=Host( .Name .. ) prints the containerName-stackName instead only the containerName when using docker-compose.

Any idea how this can be removed ? This is my current rule:

- --providers.docker.defaultRule=Host(`{{ trimPrefix `/` .Name }}.containers.myorg.com`)

If my compose stack's name is monitoring, and the container is grafana this creates:

grafana-monitoring.containers.myorg.com

instead of

grafana.containers.myorg.com

Thanks

like image 334
FreshMike Avatar asked Oct 22 '25 05:10

FreshMike


1 Answers

This seems to have worked for me:

- --providers.docker.defaultRule=Host(`{{if index .Labels "com.docker.compose.service" }}{{ index .Labels "com.docker.compose.service" }}.containers.myorg.com{{else}}{{ trimPrefix `/` .Name }}.containers.myorg.com{{end}}`)
like image 126
FreshMike Avatar answered Oct 23 '25 20:10

FreshMike