diff --git a/sandbox_dns_unix.go b/sandbox_dns_unix.go index c4da9272e5..9ed9f463ce 100644 --- a/sandbox_dns_unix.go +++ b/sandbox_dns_unix.go @@ -215,7 +215,16 @@ func (sb *sandbox) setupDNS() error { logrus.Infof("/etc/resolv.conf does not exist") } - if len(sb.config.dnsList) > 0 || len(sb.config.dnsSearchList) > 0 || len(sb.config.dnsOptionsList) > 0 { + checkLoopbackOpts := func() bool { + for _, n := range sb.config.dnsList { + if n == "127.0.0.1" { + return true + } + } + return false + } + + if checkLoopbackOpts() { var ( err error dnsList = resolvconf.GetNameservers(currRC.Content, types.IP)