add linked containers to hosts file

Docker-DCO-1.1-Signed-off-by: Bryan Murphy <bmurphy1976@gmail.com> (github: bmurphy1976)

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
Tested-by: Solomon Hykes <solomon@docker.com> (github: shykes)
Upstream-commit: 53f38a14cd6b61a6b5df68cc3694dcba2b0c1eb7
Component: engine
This commit is contained in:
Bryan Murphy
2014-05-05 19:40:27 -07:00
committed by Solomon Hykes
parent 6653f5c1ed
commit 1d128ba235
5 changed files with 106 additions and 3 deletions
@@ -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)
}