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:
committed by
Solomon Hykes
parent
6653f5c1ed
commit
1d128ba235
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user