-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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 Podman container cannot resolve DNS after enabling systemd-resolved #282361
Comments
Hi there, I don't do container alas, I am afraid I cannot help. |
That's not an issue. Do you have any idea how to "debug" this? I assumed adding aardvark-dns to the PATH might prevent it but as I mentioned, it doesn't work. Comparing two NixOS versions with systemd-resolved enabled and disabled (with $ nvd diff /nix/var/nix/profiles/system-3{4,5}-link
<<< /nix/var/nix/profiles/system-34-link
>>> /nix/var/nix/profiles/system-35-link
Selection state changes:
[C+] #1 openresolv 3.13.2
Added packages:
[A.] #1 X-Restart-Triggers-resolvconf <none>
[A.] #2 unit-network-setup.service <none>
[A.] #3 unit-resolvconf.service <none>
[A.] #4 unit-script-network-setup-start <none>
Removed packages:
[R.] #1 X-Restart-Triggers-systemd-resolved <none>
[R.] #2 etc-systemd-resolved.conf <none>
[R.] #3 unit-systemd-resolved.service <none>
Closure size: 1382 -> 1383 (25 paths added, 24 paths removed, delta +1, disk usage +3.0KiB). |
@thefossguy what does /etc/resolv.conf point to inside the container? Looking at
Which would point the same direction. Both DNS and networking in general are a very complex topic in any kind of infrastructure that is not Link-Layer bound, which is the case for qemu using slirp and containers of any variety (LXC, OCI, nspawn). For instance in this case if you're using something on top of podman (such as a form of |
I see you are specifying a network in your nix configuration however as far as I can see that network is not managed with Nix (or am I mistaken?). |
$ cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0 trust-ad
search .
$ podman exec -it gitea-govinda sh
/ # nslookup github.com
;; connection timed out; no servers could be reached
/ # nslookup google.com
;; connection timed out; no servers could be reached
/ # ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 39 Jan 21 11:33 /etc/resolv.conf
/ # cat /etc/resolv.conf
search dns.podman
nameserver 10.89.0.1 EDIT 1: Update after rebooting into a generation which has systemd-resolved disabled, following is the output: $ podman exec -it gitea-govinda sh
/ # ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 53 Jan 21 12:28 /etc/resolv.conf
/ # cat /etc/resolv.conf
search dns.podman
nameserver 10.89.0.1
options edns0
Yes, the networks get setup by an "init" service which calls this shell script. This "init" script sets up a network if one doesn't exist already. (The network name--the entire systemd user service to be honest--is influenced purely by whatever
$ podman network inspect -f {{.DNSEnabled}} containers_default
true
EDIT 2: I forgot to enable systemd-resolved in the VM. Sorry, my bad! After enabling it, the same DNS issue persists in the VM too. @benaryorg are you interested in replicating my config in a VM? If yes, I'll add a comment (shortly) on the steps. I see you took time to research a lot and I feel guilty about that (but I'm testing my patches as we speak). |
@thefossguy okay, I stand corrected, this is an actual issue within podman then, with this configuration it should work as far as I can tell. If we are on the same version then adding aardvark-dns to your path won't be necessary since it's already pulled in via podman indirectly ( You can check whether aardvark-dns is being used by looking in your host-side process list when a container is running, when using I tried stracing this on my end, here are some snippets:
The 10.0.2.3 is not actually in use on my machine (the machine's got two interfaces, one purely IPv6 sitting in a /64, one a single routed /32 IPv4).
On a hunch I decided to remove the /etc/resolv.conf symlink and replace it with a file with the exact same content (note: do not use in production, this is just for testing: The
It seems that the culprit here is that the symlink is copied rather than the underlying file which causes the slirp side of things to break.
This sandbox seems to be 100% hardcoded to those directories. I do not see a lot of solutions here to be honest. |
Wow, okay, I should've just checked the issues in slirp4netns for a split second there. An upstream bug report exists ( |
@benaryorg, please use my NixOS config + installer script to create a VM of your own and test it (if you are willing to do so). Please follow these steps to install NixOS with my config in a VM:
(Warning: This is a very opinionated NixOS config so there will be some weird things like the first launch of Neovim will install the plugins and the sort. Sorry about that.) With the checked-out commit, systemd-resolved is disabled. So, with the first generation, DNS resolution will work form the container(s). After adding the line EDIT: Please go through the edits on my previous comment. :) |
Okay this did end up working! 🎉 So yeah, for whatever reason, No need to replicate my NixOS config. This is resolved. Thank you @benaryorg |
Describe the bug
As the title mentions, a rootless podman container is unable to resolve DNS after enabling systemd-resolved via the
services.resolved
module.Since home-manager does not have a module for rootless podman containers, I am manually creating a systemd service to start a Gitea container at boot (source). This Gitea container handles my personal Gitea instance where I have a push mirror to my GitHub repositories. I push to Gitea which in turn pushes to GitHub.
With
services.resolved.enable = true;
in myconfiguration.nix
file, I get the following error in the container's logs:Since
aardvark-dns
is the DNS server that the upstream (Podman) documentation recommends, I also tried puttingaardvark-dns
in thePATH
environment for the systemd user service like so:But this doesn't seem to work either.
Steps To Reproduce
services.resolved
is disabled/unset.podman exec -it gitea-govinda sh
.nslookup github.com
should give you a familiar, positive-feeling output.services.resolved
in the NixOS configuration and reboot (haven't tried with anixos-rebuild switch
).podman exec -it gitea-govinda sh
.nslookup github.com
would result in some sort of error. It says;; connection timed out; no servers could be reached
on my end.Expected behavior
I expect the DNS lookup to work since the distros (RHEL and Fedora) where Podman is the first class citizen does use systemd-resolved and DNS lookup does work there.
Screenshots
N/A
Additional context
N/A
Notify maintainers
Pinging the last three people that modified this module: @benaryorg @RaitoBezarius @roberth
Metadata
Add a 👍 reaction to issues you find important.
The text was updated successfully, but these errors were encountered: