[proxy] Add --hostname-from-label

This allows registering container hostnames based on a label provided when
creating the container.
This commit is contained in:
Alfonso Acosta authored and Paul Bellamy committed 2015-09-04 17:02:07 +01:00
1 parent 32a82f2d0e
commit ce5dd847e9
6 files changed
+92 -29

No files matched your search

+7 -2
View File
@@ -59,8 +59,13 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
if err := i.setWeaveWaitEntrypoint(container.Config); err != nil {
return err
}
containerName := r.URL.Query().Get("name")
hostname := i.proxy.hostnameMatchRegexp.ReplaceAllString(containerName, i.proxy.HostnameReplacement)
hostname := r.URL.Query().Get("name")
if i.proxy.Config.HostnameFromLabel != "" {
if labelValue, ok := container.Labels[i.proxy.Config.HostnameFromLabel]; ok {
hostname = labelValue
}
}
hostname = i.proxy.hostnameMatchRegexp.ReplaceAllString(hostname, i.proxy.HostnameReplacement)
if err := i.setWeaveDNS(&container, hostname); err != nil {
return err
}
+1
View File
@@ -39,6 +39,7 @@ func dockerAPIEndpoint(endpoint string) *regexp.Regexp {
}
type Config struct {
HostnameFromLabel string
HostnameMatch string
HostnameReplacement string
ListenAddrs []string