diff --git a/provider/docker/docker.go b/provider/docker/docker.go index b2128bbfc..6ecbc775d 100644 --- a/provider/docker/docker.go +++ b/provider/docker/docker.go @@ -542,6 +542,9 @@ func (p *Provider) getFrontendRule(container dockerData) string { if label, err := getLabel(container, "traefik.frontend.rule"); err == nil { return label } + if labels, err := getLabels(container, []string{"com.docker.compose.project", "com.docker.compose.service"}); err == nil { + return "Host:" + p.getSubDomain(labels["com.docker.compose.service"]+"."+labels["com.docker.compose.project"]) + "." + p.Domain + } if len(p.Domain) > 0 { return "Host:" + p.getSubDomain(container.ServiceName) + "." + p.Domain } diff --git a/provider/docker/service_test.go b/provider/docker/service_test.go index 46749c553..a5f03b8fb 100644 --- a/provider/docker/service_test.go +++ b/provider/docker/service_test.go @@ -133,7 +133,7 @@ func TestDockerGetServiceFrontendRule(t *testing.T) { }{ { container: containerJSON(name("foo")), - expected: "Host:foo.", + expected: "", }, { container: containerJSON(labels(map[string]string{