-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Netfilter config is not handled on runsc boot, reopen of: "DNS not working in Docker Compose" #7469
Comments
And yes, it works if correct port is used:
From above UDP is remapped:
|
@pkit I am not sure from your description as to what is not working with gVisor. Can you provide a concise explanation of what you expect to work and what is not working? I am not averse to picking up netfilter settings at startup but our iptables implementation is not as complete as linux and picking up netfilter rules entails a bit of risk. @kevinGC should have a better answer for you. |
@hbhasker It also means that there is a little bit of security risk in current implementation, for example in case where startup rules I have started implementation anyway. Will update when we get to some results. |
FYI, the place in moby/docker where that resolver is set up: here |
btw I was thinking about this and not sure copying in the rules will work. Since if docker is redirecting it a loopback address like 127.0.0.11 that rule will direct it to the sentry's internal loopback. But dockerd does not listen on the sentry's internal loopback but the host's container namespaces loopback. |
You tested by entering the host container namespace that dig is not running inside gvisor. For that you will have to use docker exec to enter gvisor and run the command. |
Yup, did that too IIRC. But will re-check. |
@hbhasker yup, you were right, it doesn't route to 127.0.0.11 from gvisor. |
@hbhasker still not having iptables set up during boot is a security problem. Traffic may be restricted in vanilla docker/containerd but will be unrestricted under gvisor. |
In general we do not trust the sentry so any enforcement in the sentry isn't safe from potential compromise. E.g a privilege escalation bug in gvisor could allow a user to delete any such network enforcement via iptable. As such we expect that all such enforcement should happen outside the container on the host. |
As for this specific problem maybe the right solution for gvisor would be to generate a resolv.conf pointing to the proper IP/ port for DNS. |
That's an internal DNS. It doesn't have non |
For others running into this, I was able to work around this issue by setting |
A friendly reminder that this issue had no activity for 120 days. |
This issue has been closed due to lack of activity. |
Please repoen because this issue is still present and a problem when using gVisor with docker compose. |
This is a tough problem to solve. At a high level: putting an application inside gVisor sandboxes it, but Compose puts the DNS server outside the sandbox. I don't know of an especially simple solution. As Ian mentioned in the other bug, the best way to deal with this is to change the DNS server in use. If you need the Compose DNS server specifically, you could modify iptables rules outside the sandbox to redirect DNS traffic to Compose DNS. FWIW we now support scraping netfilter rules from the host (see b119cc3 and e7e8d0f) that can be enabled via the I'd love a better solution than "add gVisor-specific configuration", but in this case I'm not sure what that would be. |
Is there, maybe, a generic way to add an nftables nat/redirect rule to capture the DNS lookups from within the sandbox to the host loopback DNS server? I am thinking of a (pseudo) static IP address specified as DNS server for the containers in the gVisor sandbox (e.g. via docker-compose) that can be redirected generically to the compose-managed host DNS resolver. That might potentially be generic across all containers? |
I'm not sure of a generic way to do it, but it could certainly be done. Note that I'm not familiar with Docker Compose, so I'm not sure how difficult this is.
|
Description
See #115
Which was closed pretty prematurely.
The problem is that docker-compose uses a special netfilter config that remaps
127.0.0.11
in a pretty funny way.I.e.:
That's why udp to
127.0.0.11:53
doesn't work.Which brings us to the bug itself: if gvisor already copies
lo
routes andarp
config, why shouldn't it do the same fornetfilter
stuff?I think it should, otherwise these bugs will crop up.
Will try to assemble a PR on that soon.
Steps to reproduce
See #115
runsc version
docker version (if using docker)
uname
Linux machine1 5.17.2-051702-generic #202204111357-Ubuntu SMP PREEMPT Mon Apr 11 14:08:56 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
kubectl (if using Kubernetes)
No response
repo state (if built from source)
No response
runsc debug logs (if available)
No response
The text was updated successfully, but these errors were encountered: