diff --git a/daemon/libnetwork/sandbox_linux.go b/daemon/libnetwork/sandbox_linux.go index 27a37dfd8c..878ff44495 100644 --- a/daemon/libnetwork/sandbox_linux.go +++ b/daemon/libnetwork/sandbox_linux.go @@ -366,6 +366,11 @@ func (sb *Sandbox) populateNetworkResourcesOS(ctx context.Context, ep *Endpoint) if ep.needResolver() { sb.startResolver(false) + } else { + // Make sure /etc/resolv.conf is set up. + if err := sb.updateDNS(ep.getNetwork().enableIPv6); err != nil { + return err + } } if i != nil && i.srcName != "" { @@ -448,10 +453,6 @@ func (sb *Sandbox) populateNetworkResourcesOS(ctx context.Context, ep *Endpoint) } sb.addHostsEntries(ctx, ep.getEtcHostsAddrs()) - // Make sure /etc/resolv.conf is set up. - if err := sb.updateDNS(ep.getNetwork().enableIPv6); err != nil { - return err - } // Populate load balancer only after updating all the other // information including gateway and other routes so that