diff --git a/network/endpoint_windows.go b/network/endpoint_windows.go index 742d338c21..c1fd497c0d 100644 --- a/network/endpoint_windows.go +++ b/network/endpoint_windows.go @@ -94,12 +94,17 @@ func (nw *network) newEndpointImpl(epInfo *EndpointInfo) (*endpoint, error) { } }() - // Attach the endpoint. - log.Printf("[net] Attaching endpoint %v to container %v.", hnsResponse.Id, epInfo.ContainerID) - err = hcsshim.HotAttachEndpoint(epInfo.ContainerID, hnsResponse.Id) - if err != nil { - log.Printf("[net] Failed to attach endpoint: %v.", err) - return nil, err + // Attach the endpoint happens on join + if len(epInfo.ContainerID) > 0 { + log.Printf("[net] Attaching endpoint %v to container %v.", hnsResponse.Id, epInfo.ContainerID) + err = hcsshim.HotAttachEndpoint(epInfo.ContainerID, hnsResponse.Id) + if err != nil { + log.Printf("[net] Failed to attach endpoint: %v.", err) + return nil, err + } + } else { + // Attach the endpoint happens on join + log.Printf("[net] Skipping Attaching endpoint %v to container %v, as this will happen in NetworkDriver/Join", hnsResponse.Id, epInfo.ContainerID) } // Create the endpoint object.