Update /etc/hosts when linked container is restarted

Carry of #7092

closes #7092
fixes #6350

/cc @vieux
Should be fixed now. Thanks!

-Erik

On Aug 25, 2014, at 11:32 AM, Tibor Vass <notifications@github.com> wrote:

> In daemon/container.go:
> 
> > @@ -878,6 +886,26 @@ func (container *Container) setupContainerDns() error {
> >  	return ioutil.WriteFile(container.ResolvConfPath, resolvConf, 0644)
> >  }
> >  
> > +func (container *Container) updateParentsHosts() error {
> > +	parents, err := container.daemon.Parents(container.Name)
> > +	if err != nil {
> > +		return err
> > +	}
> > +	for _, cid := range parents {
> > +		if cid == "0" {
> > +			continue
> > +		}
> > +
> > +		c := container.daemon.Get(cid)
> > +		if c != nil && !container.daemon.config.DisableNetwork && !container.hostConfig.NetworkMode.IsContainer() && !container.hostConfig.NetworkMode.IsHost() {
> > +			if err := etchosts.Update(c.HostsPath, container.NetworkSettings.IPAddress, container.Name[1:]); err != nil {
> > +				return fmt.Errorf("Failed to update parent: %v", err)
> Error message could be more descriptive: Failed to update /etc/hosts of parent container.
> 
> —
> Reply to this email directly or view it on GitHub.
>