diff --git a/libnetwork/resolver.go b/libnetwork/resolver.go index 83427c5ca9..854ef295bd 100644 --- a/libnetwork/resolver.go +++ b/libnetwork/resolver.go @@ -324,6 +324,13 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { continue } } + // If two go routines are executing in parralel one will + // block on the Once.Do and in case of error connecting + // to the external server it will end up with a nil err + // but extConn also being nil. + if extConn == nil { + continue + } // Timeout has to be set for every IO operation. extConn.SetDeadline(time.Now().Add(extIOTimeout))