1
0
mirror of https://github.com/containous/traefik.git synced 2024-12-22 13:34:03 +03:00

Docker corrections with long hostnames

This commit is contained in:
emile 2015-09-10 15:12:28 +02:00
parent 0dde11aa86
commit e60e955f90
2 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,7 @@ var DockerFuncMap = template.FuncMap{
return value
}
}
return container.Config.Hostname
return getHost(container)
},
"getPort": func(container docker.Container) string {
for key, value := range container.Config.Labels {
@ -37,6 +37,9 @@ var DockerFuncMap = template.FuncMap{
}
return ""
},
"replace": func(s1 string, s2 string, s3 string) string {
return strings.Replace(s3, s1, s2, -1)
},
"getHost": getHost,
}
@ -113,5 +116,5 @@ func getHost(container docker.Container) string {
return value
}
}
return strings.TrimPrefix(container.Name, "/")
return strings.Replace(strings.Replace(container.Name, "/", "", -1), ".", "-", -1)
}

View File

@ -1,5 +1,5 @@
[backends]{{range .Containers}}
[backends.backend-{{getBackend .}}.servers.server-{{.Name | replace "/"}}]
[backends.backend-{{getBackend .}}.servers.server-{{.Name | replace "/" "" | replace "." "-"}}]
url = "http://{{.NetworkSettings.IPAddress}}:{{getPort .}}"
{{end}}