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

Missing resolv.conf in WSL2 #8089

Closed
c-goes opened this issue Oct 21, 2020 · 4 comments · Fixed by #8111
Closed

Missing resolv.conf in WSL2 #8089

c-goes opened this issue Oct 21, 2020 · 4 comments · Fixed by #8111
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@c-goes
Copy link

c-goes commented Oct 21, 2020

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

When installing Ubuntu 20.04 rootfs for WSL
and Podman 2.1.1 no container starts because of missing /run/systemd/resolve/resolv.conf.

Steps to reproduce the issue:

  1. Install Ubuntu 20.04 via tar in WSL2

  2. Install Podman

  3. Run a container as root: podman run hello-world

Describe the results you received:

# podman run hello-world
Error: error creating resolv.conf for container 59dc1c8f45abe1b1d7c880a21e315948ee36a5951be6be31945334b4a87ec716: unable to read /run/systemd/resolve/resolv.conf: open /run/systemd/resolve/resolv.conf: no such file or directory

Describe the results you expected:

Container starts without errors.

Additional information you deem important (e.g. issue happens only occasionally):

It works if I run cp /etc/resolv.conf /run/systemd/resolve/resolv.conf beforehand. But I need to repeat this every time I restart WSL.

Output of podman version:

(paste your output here)

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.16.1
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.0.20, commit: '
  cpus: 8
  distribution:
    distribution: ubuntu
    version: "20.04"
  eventLogger: file
  hostname: wslhost
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 4.19.128-microsoft-standard
  linkmode: dynamic
  memFree: 6718386176
  memTotal: 8345993216
  ociRuntime:
    name: runc
    package: 'runc: /usr/sbin/runc'
    path: /usr/sbin/runc
    version: 'runc version spec: 1.0.1-dev'
  os: linux
  remoteSocket:
    path: /run/podman/podman.sock
  rootless: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 0
  swapTotal: 0
  uptime: 25m 40.16s
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 6
    paused: 0
    running: 0
    stopped: 6
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 14
  runRoot: /var/run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 2.0.0
  Built: 0
  BuiltTime: Thu Jan  1 01:00:00 1970
  GitCommit: ""
  GoVersion: go1.15.2
  OsArch: linux/amd64
  Version: 2.1.1

Package info (e.g. output of rpm -q podman or apt list podman):

podman/unknown,now 2.1.1~2 amd64 [installed]
podman/unknown 2.1.1~2 arm64
podman/unknown 2.1.1~2 armhf
podman/unknown 2.1.1~2 s390x

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

WSL2

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 21, 2020
@Luap99
Copy link
Member

Luap99 commented Oct 21, 2020

Can you check if /etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf?

@c-goes
Copy link
Author

c-goes commented Oct 21, 2020

Can you check if /etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf?

# ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Oct 16 23:39 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

Interestingly, when installed via appx-file, WSL-Ubuntu has another link

lrwxrwxrwx  1 root root         29 Oct  5 11:31 resolv.conf -> ../run/resolvconf/resolv.conf

But I need to use the Ubuntu installed via rootfs with Podman.

@c-goes
Copy link
Author

c-goes commented Oct 22, 2020

Probably related: #7616

@Luap99
Copy link
Member

Luap99 commented Oct 22, 2020

What the content in /run/systemd/resolve/stub-resolv.conf?

I guess it is only the nameserver 127.0.0.53 entry. We cannot use this file as source since this ip will not be reachable from within the container. The /run/systemd/resolve/stub-resolv.conf and /run/systemd/resolve/resolv.conf files are managed by systemd-resolved. Only /run/systemd/resolve/resolv.conf will contain the real nameserver entries. That's why we have to use this file as source even if stub-resolv.conf is symlinked.

This is to some degree a configuration problem with your ubuntu image since systemd cannot be run in wsl AFAIK and therefore systemd-resolved wont work. Does the dns resolution even work with your wsl image?

However, we use default entries if /etc/resolv.conf is empty, so I think it would make sense to also add default ones if the file does not exists.

Luap99 pushed a commit to Luap99/libpod that referenced this issue Oct 22, 2020
If the resolv.conf file is empty we provide default dns servers.
If the file does not exists we error and don't create the
container. We should also provide the default entries in this
case. This is also what docker does.

Fixes containers#8089

Signed-off-by: Paul Holzinger <[email protected]>
@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
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants