diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-02 14:57:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 14:57:37 -0500 |
commit | aab8a934f5bd9bc58959c49f334d3ba57a0f5135 (patch) | |
tree | 0870e9b21e64d4347ea8024ccc8dba0ff3a263e0 /libpod/runtime_pod_infra_linux.go | |
parent | 628b0d79b523953cc6aa9b48bd91d04d0843353b (diff) | |
parent | 931ea939ac85bc0e64d12dc34ac920e9e91c4277 (diff) | |
download | podman-aab8a934f5bd9bc58959c49f334d3ba57a0f5135.tar.gz podman-aab8a934f5bd9bc58959c49f334d3ba57a0f5135.tar.bz2 podman-aab8a934f5bd9bc58959c49f334d3ba57a0f5135.zip |
Merge pull request #9185 from mheon/pod_no_network
Allow pods to use --net=none
Diffstat (limited to 'libpod/runtime_pod_infra_linux.go')
-rw-r--r-- | libpod/runtime_pod_infra_linux.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go index dd957527d..564851f4e 100644 --- a/libpod/runtime_pod_infra_linux.go +++ b/libpod/runtime_pod_infra_linux.go @@ -94,8 +94,16 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm } } - // Since user namespace sharing is not implemented, we only need to check if it's rootless - if !p.config.InfraContainer.HostNetwork { + switch { + case p.config.InfraContainer.HostNetwork: + if err := g.RemoveLinuxNamespace(string(spec.NetworkNamespace)); err != nil { + return nil, errors.Wrapf(err, "error removing network namespace from pod %s infra container", p.ID()) + } + case p.config.InfraContainer.NoNetwork: + // Do nothing - we have a network namespace by default, + // but should not configure slirp. + default: + // Since user namespace sharing is not implemented, we only need to check if it's rootless netmode := "bridge" if isRootless || p.config.InfraContainer.Slirp4netns { netmode = "slirp4netns" @@ -106,8 +114,6 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm // PostConfigureNetNS should not be set since user namespace sharing is not implemented // and rootless networking no longer supports post configuration setup options = append(options, WithNetNS(p.config.InfraContainer.PortBindings, false, netmode, p.config.InfraContainer.Networks)) - } else if err := g.RemoveLinuxNamespace(string(spec.NetworkNamespace)); err != nil { - return nil, errors.Wrapf(err, "error removing network namespace from pod %s infra container", p.ID()) } // For each option in InfraContainerConfig - if set, pass into |