func (proxy *Proxy) RewriteEtcHosts(hostsPath, fqdn string, ips []*net.IPNet, extraHosts []string) error {
	hostsPathDir := path.Dir(hostsPath)
	mnt := "/container"
	mntHosts := path.Join(mnt, path.Base(hostsPath))
	var buf bytes.Buffer
	writeEtcHostsContents(&buf, fqdn, ips, extraHosts)
	contents := buf.String()
	cmdLine := fmt.Sprintf("echo '%s' > %s && rm -f %s && echo '%s' > %s", contents, mntHosts, mntHosts, contents, mntHosts)
	mounts := []string{hostsPathDir + ":" + mnt}
	proxy.runTransientContainer([]string{"sh"}, []string{"-c", cmdLine}, mounts)
	return nil
}
// rewrite /etc/hosts, unlinking the file (so Docker does not modify it again) but
// leaving it with valid contents...
rewrite /etc/hosts, unlinking the file (so Docker does not modify it again) but
leaving it with valid contents
// rewrite / etc / hosts unlinking the file ( so Docker does not modify it again ) but // leaving it with valid contents ...
func (proxy *Proxy) RewriteEtcHosts(hostsPath, fqdn string, ips []*net.IPNet, extraHosts []string) error {
	hostsPathDir := path.Dir(hostsPath)
	mnt := "/container"
	mntHosts := path.Join(mnt, path.Base(hostsPath))
	var buf bytes.Buffer
	writeEtcHostsContents(&buf, fqdn, ips, extraHosts)
	contents := buf.String()
	cmdLine := fmt.Sprintf("echo '%s' > %s && rm -f %s && echo '%s' > %s", contents, mntHosts, mntHosts, contents, mntHosts)
	mounts := []string{hostsPathDir + ":" + mnt}
	proxy.runTransientContainer([]string{"sh"}, []string{"-c", cmdLine}, mounts)
	return nil
}
func ( proxy * Proxy ) RewriteEtcHosts ( hostsPath , fqdn string , ips [ ] * net . IPNet , extraHosts [ ] string ) error { hostsPathDir := path . Dir ( hostsPath ) mnt := " " mntHosts := path . Join ( mnt , path . Base ( hostsPath ) ) var buf bytes . Buffer writeEtcHostsContents ( & buf , fqdn , ips , extraHosts ) contents := buf . String ( ) cmdLine := fmt . Sprintf ( " " , contents , mntHosts , mntHosts , contents , mntHosts ) mounts := [ ] string { hostsPathDir + " " + mnt } proxy . runTransientContainer ( [ ] string { " " } , [ ] string { " " , cmdLine } , mounts ) return nil }
rewrite /etc/hosts, unlinking the file (so Docker does not modify it again) but
leaving it with valid contents
rewrite / etc / hosts unlinking the file ( so Docker does not modify it again ) but leaving it with valid contents