-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
resolv.conf inside container does not get updated when it changes on host #14412
Comments
Podman is not a daemon, there is no way for podman to monitor /etc/resolv.conf and update all containers when it changes. That said I understand the usecase. Currently a container restart should make it work again. However I understand that this is not desirable in most cases. Maybe podman can provide a way to only update the /etc/resolv.conf, something like |
Yes, I'm not thinking of having podman do it itself, but NetworkManager (and any other dhcp client) have hooks :) With a If it's just copying resolv.conf to container userdata as I pointed out though I'm not sure it's worth adding the bloat, I see we can get '{{.ResolvConfPath}}' from podman inspect so the script itself isn't that hard to make even without a command; I was mostly wondering if anyone had done it before. I'll be happy to submit such a network dispatched script to contrib/networkmanager/refresh_containers_dns.sh or something if that sounds like a good idea. The only "problem" I can think of is since that is a bind mount we can't atomically replace resolv.conf, but have to write to it -- so if doing it normally there's a short window where resolv.conf will be empty in the container. |
Sounds good.
We already do this with network connect/disconnect, so I think we can also do it here. |
Thanks! Making a simple dispatcher script that just overwrites dns with new ones whenever a configuration change happens is easy, but there doesn't seem to be any event that includes the former dns if e.g. you have this chain of events: 1/ ethernet link, 2/ vpn up with their dns, 3/ vpn down -- at this point you'd be left with the vpn dns which isn't good. With a local resolver networkmanager will make things work as expected so it's just easier that way. I'm closing this as my issue is then resolved, I wouldn't know if it's worth adding to the FAQ or some wiki page about networking as advice instead. Thank you very much for being reactive anyway :) |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
(or feature?)
Description
Running containers before the network is fully setup (e.g. LTE internet that takes a minute to setup), or just changing network (e.g. laptop moving from work to home network, or using a VPN's dns server and stopping the VPN) can lead to having an invalid /etc/resolv.conf inside containers.
Unfortunately, it doesn't look like the container keeps up with such changes -- the /etc/resolv.conf inside my containers keep whatever original value it found when the container was created, and doesn't seem to pick up new values.
Would updating it be possible? (ideas in additional information section)
Steps to reproduce the issue:
Describe the results you received:
DNS no longer works in containers
Describe the results you expected:
DNS keeps working.
Additional information you deem important (e.g. issue happens only occasionally):
Okay, first: the "obvious solution" to this is using something like systemd resolved or dnsmasq, with /etc/resolv.conf pointing to localhost -- that's what I have on my laptop and why I hadn't noticed the problem until now.
If a dns proxy/cache is used, the containers can keep using that local address and the local server will just use appropriate dns; which even allows split DNS, local dnssec validation and all the cool things.
I've been using dnsmasq with NetworkManager forever so I'd be willing to make that step, but would like to explore alternatives first (this might have been more appropriate as Q&A, sorry -- but I think whatever comes out of it is worth adding to documentation, if only "if you change networks use resolved or another local resolver" to the FAQ)
So, as far as I can see, /etc/resolv.conf is mounted from
<storage>/overlay-containers/<id>/userdata/resolv.conf
Updating that file obviously works as expected, and it'd be easy enough to create a NetworkManager dispatcher script that updates these when DNS change. I don't see any such script anywhere, is it known to have been done before?
Are there "helpful wrappers" to manipulate dns like podman run --dns once a container is already started?
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
No and Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
headless computer board
The text was updated successfully, but these errors were encountered: