From 8cd290389844835220dad121cf9f073590f44461 Mon Sep 17 00:00:00 2001 From: Bryan Murphy Date: Mon, 7 Apr 2014 18:34:07 +0000 Subject: [PATCH] add linked containers to hosts file Docker-DCO-1.1-Signed-off-by: Bryan Murphy (github: bmurphy1976) Docker-DCO-1.1-Signed-off-by: Solomon Hykes (github: shykes) Tested-by: Solomon Hykes (github: shykes) --- networkfs/etchosts/etchosts.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/networkfs/etchosts/etchosts.go b/networkfs/etchosts/etchosts.go index 1697970..144a039 100644 --- a/networkfs/etchosts/etchosts.go +++ b/networkfs/etchosts/etchosts.go @@ -15,7 +15,7 @@ var defaultContent = map[string]string{ "ip6-allrouters": "ff02::2", } -func Build(path, IP, hostname, domainname string) error { +func Build(path, IP, hostname, domainname string, extraContent *map[string]string) error { content := bytes.NewBuffer(nil) if IP != "" { if domainname != "" { @@ -30,5 +30,14 @@ func Build(path, IP, hostname, domainname string) error { return err } } + + if extraContent != nil { + for hosts, ip := range *extraContent { + if _, err := content.WriteString(fmt.Sprintf("%s\t%s\n", ip, hosts)); err != nil { + return err + } + } + } + return ioutil.WriteFile(path, content.Bytes(), 0644) }