container: do not try to join networkNS if using the node namespace
@@ -1067,6 +1067,12 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
}
}
+ // If the sandbox is configured to run in the host network, do not create a new network namespace
+ if sb.HostNetwork() {
+ if err := specgen.RemoveLinuxNamespace(string(rspec.NetworkNamespace)); err != nil {
+ return nil, err
+ }
+ } else {
netNsPath := sb.NetNsPath()
if netNsPath == "" {
// The sandbox does not have a permanent namespace,
@@ -1077,6 +1083,7 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
if err := specgen.AddOrReplaceLinuxNamespace(string(rspec.NetworkNamespace), netNsPath); err != nil {
return nil, err
}
+ }
imageSpec := containerConfig.GetImage()
if imageSpec == nil {
