Docker corrections with long hostnames
This commit is contained in:
parent
0dde11aa86
commit
e60e955f90
2 changed files with 6 additions and 3 deletions
|
@ -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)
|
||||
}
|
|
@ -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}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue