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

nixos containers: boot race condition around copying the host's resolv.conf with DHCP #196370

Open
steveej opened this issue Oct 17, 2022 · 2 comments
Labels
0.kind: bug 6.topic: nixos-container Imperative and declarative systemd-nspawn containers

Comments

@steveej
Copy link
Contributor

steveej commented Oct 17, 2022

Describe the bug

A clear and concise description of what the bug is.

Steps To Reproduce

Steps to reproduce the behavior:

  1. set up a NixOS host with all default network settings (DHCP)
  2. declare a NixOS container with all default network settings (share host's container namespace and copy it's resolv.conf) and with container.<name>.autoStart = true
  3. reboot the host
  4. observe the /etc/resolv.conf in the container even after the host's DHCP request has successfully populated the host's resolv.conf. compare host and container resolv.conf:
    [root@github-runner-host:~]# cat /etc/resolv.conf
    # Generated by resolvconf
    domain contaboserver.net
    nameserver 161.97.189.51
    nameserver 161.97.189.52
    options edns0
    
    [root@github-runner-host:~]# nixos-container run githubRunner0 cat /etc/resolv.conf
    # Generated by resolvconf
    options edns0
    options edns0
    
  5. reboot the container and see the resolv.conf updated
    [root@github-runner-host:~]# nixos-container restart githubRunner0
    
    [root@github-runner-host:~]# nixos-container run githubRunner0 cat /etc/resolv.conf
    # Generated by resolvconf
    domain contaboserver.net
    nameserver 161.97.189.51
    nameserver 161.97.189.52
    options edns0
    options edns0
    

Expected behavior

container has functional DNS resolving on first boot

Metadata

rev: 83b198a

Workaround

tell systemd.nspawn to bind-mount the hosts's resolv.conf:

          extraFlags = [
            "--resolv-conf=bind-host"
          ];
@veprbl veprbl added the 6.topic: nixos-container Imperative and declarative systemd-nspawn containers label Oct 24, 2022
@vincentbernat
Copy link
Member

The workaround seems to work fine for me. It looks like it could be applied for everyone instead of copying /etc/resolv.conf on start.

@vincentbernat
Copy link
Member

Related: #162686.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: nixos-container Imperative and declarative systemd-nspawn containers
Projects
None yet
Development

No branches or pull requests

3 participants