From cfcd92847684fc65949350b7cdc4769ad1099d46 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 25 Jul 2018 15:15:13 +0200 Subject: network: add support for rootless network with slirp4netns slirp4netns is required to setup the network namespace: https://github.com/rootless-containers/slirp4netns Signed-off-by: Giuseppe Scrivano Closes: #1156 Approved by: rhatdan --- pkg/spec/createconfig.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/spec') diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 0bd6c6d1c..fb45f042b 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -381,8 +381,12 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime) ([]lib return nil, errors.Wrapf(err, "container %q not found", c.NetMode.ConnectedContainer()) } options = append(options, libpod.WithNetNSFrom(connectedCtr)) - } else if !rootless.IsRootless() && !c.NetMode.IsHost() && !c.NetMode.IsNone() { - postConfigureNetNS := (len(c.IDMappings.UIDMap) > 0 || len(c.IDMappings.GIDMap) > 0) && !c.UsernsMode.IsHost() + } else if !c.NetMode.IsHost() && !c.NetMode.IsNone() { + isRootless := rootless.IsRootless() + postConfigureNetNS := isRootless || (len(c.IDMappings.UIDMap) > 0 || len(c.IDMappings.GIDMap) > 0) && !c.UsernsMode.IsHost() + if isRootless && len(portBindings) > 0 { + return nil, errors.New("port bindings are not yet supported by rootless containers") + } options = append(options, libpod.WithNetNS(portBindings, postConfigureNetNS, networks)) } -- cgit v1.2.3-54-g00ecf