Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rootless containers should have dedicated netns&veth under the singleton slirp4netns instance #1733

Closed
AkihiroSuda opened this issue Oct 31, 2018 · 12 comments
Assignees
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. rootless

Comments

@AkihiroSuda
Copy link
Collaborator

AkihiroSuda commented Oct 31, 2018

Is this a BUG REPORT or FEATURE REQUEST?:

[//]: # kind feature

Description

Rootless containers should use a singleton slirp4netns instance, and create dedicated netns (and veth) under the slirp4netns netns

Steps to reproduce the issue:

  1. Create a rootless container

  2. Create the second one

Describe the results you received:

Dedicated slirp4netns is created for each of the containers. i.e. the two containers cannot communicate to each other.

Describe the results you expected:

Only single slirp4netns should be launched, and dedicated network namespaces and vEths under the slirp4netns should be created for each of the containers.
The containers should be able to communicate via vEths.

@AkihiroSuda AkihiroSuda changed the title rootless containers should share the slirp4netns instance rootless containers should have dedicated netns&veth under the singleton slirp4netns instance Oct 31, 2018
@rhatdan
Copy link
Member

rhatdan commented Dec 22, 2018

@AkihiroSuda @giuseppe Any movement on this?

@giuseppe
Copy link
Member

no, I am not sure about the design here and if having a single instance of slirp4netns is what we want

@AkihiroSuda
Copy link
Collaborator Author

Any other idea for supporting inter-container communication?

@giuseppe
Copy link
Member

I think they should be set to run in the same pod

@mgoltzsche
Copy link
Contributor

mgoltzsche commented Dec 23, 2018

I agree when two containers should communicate on the same host ideally they should run in a pod. However the ability to make multiple pods communicate with each other provides more flexibility: Picture a Docker Compose project where multiple services use the same port and still communicate with each other. Now if you want to run this with podman you have to change the configuration or you even have to change the image.
Basically it means to lower the isolation between containers although you may not want to do this in every case or it just becomes cumbersome: You cannot simply add any new container/service and make it communicate with your existing ones without touching the latter.

I am facing the same problem in ctnr (I am thinking about stopping development in favour of podman):
Moving the whole container execution into a shared netns doesn't seem to be ideal since, while it just concerns rootless networking, it has a huge impact on the whole container engine design and may result in unnecessary complexity.
Thus I thought about implementing such a feature as a CNI plugin that executes other nested plugins within a shared, slirped netns - it is a network concern after all. This approach also has some drawbacks as the CNI plugin would need to implement some container engine specific features and manage one or multiple of such shared netns/containers implicitly. However it encapsulates this network-related logic behind CNI. lt would allow easy exchange in the future in case of new kernel features that may simplify everything. Also it would provide consistent usability with plain runc (since it can ensure that resources like a bridge's veth are released from the shared netns when a container is terminated using plain runc outside the shared netns). Correspondingly multiple projects could benefit from such a CNI plugin.

@giuseppe
Copy link
Member

@AkihiroSuda is already working on exposing network ports to the slirp4netns network. Once that lands, we will be able to expose ports from the host to the network namespace of each pod/container we wish to. This is the way, IMO, for different containers/pods to communicate, only by a selected and controlled set of ports.

Said so, I agree on the CNI idea. It would be nice to enable support for CNI in rootless mode, so that these more complex configurations can be addressed as plugins.

@rhatdan
Copy link
Member

rhatdan commented Mar 8, 2019

@giuseppe Is this fixed, can't we close this?

@rhatdan
Copy link
Member

rhatdan commented Mar 8, 2019

Fixed in master.

@tmds
Copy link
Contributor

tmds commented Jul 8, 2020

@AkihiroSuda is already working on exposing network ports to the slirp4netns network. Once that lands, we will be able to expose ports from the host to the network namespace of each pod/container we wish to.

@AkihiroSuda Is there a way to expose a host port to a container? For example, I have nginx running on the host at localhost:80, can I make it accessible to a specific container?

@AkihiroSuda
Copy link
Collaborator Author

AkihiroSuda commented Jul 8, 2020

slirp4netns can expose localhost:80 on the host as 10.0.2.2:80 in the container, when slirp4netns process is not launched with --disable-host-loopback.
But Podman does not provide a way to launch slirp4netns without --disable-host-loopback AFAIK.

A hacky way would be like this (untested)

$ mv slirp4netns slirp4netns.real
$ cat > slirp4netns <<EOF
#!/bin/sh
set -eu
exec slirp4netns.real "$(echo $@ | sed -e s/--disable-host-loopback//g)"
EOF
$ chmod +x slirp4netns

@tmds
Copy link
Contributor

tmds commented Jul 9, 2020

@AkihiroSuda thank you for the info. I guess podman disables this by default for security. It would be nice to have a flag to expose the host loopback.

@AkihiroSuda
Copy link
Collaborator Author

PR: #7460

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. rootless
Projects
None yet
Development

No branches or pull requests

6 participants