From afccf9c687bb8fc6371893284e672ccf35d94fb9 Mon Sep 17 00:00:00 2001 From: Santhosh Manohar Date: Fri, 18 Nov 2016 07:02:26 -0800 Subject: [PATCH] Serialize resolver Start and Stop Signed-off-by: Santhosh Manohar --- resolver.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/resolver.go b/resolver.go index e92c24887c..e6f81e4c79 100644 --- a/resolver.go +++ b/resolver.go @@ -145,6 +145,14 @@ func (r *resolver) Start() error { return fmt.Errorf("setting up IP table rules failed: %v", err) } + // If the container goes down quickly after start resolver.Stop() can + // get called before Start() completes. Check if the socket is still + // valid before Activating the DNS server. This avoids a panic in dns + // libarary code because of missing nil check for interface's data. + // github.com/docker/docker/issues/28112 + if r.conn == nil { + return fmt.Errorf("resolver udp socket invalid") + } s := &dns.Server{Handler: r, PacketConn: r.conn} r.server = s go func() {