podman: Podman Init wont Resolve DNS Windows WSL
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Podman machine unable to resolve DNS
Steps to reproduce the issue:
- podman machine init
Describe the results you received:
When trying to install packages for Fedora 35 the WSL VM is unable to resolve the repo mirrors
Errors during downloading metadata for repository 'fedora':
- Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-35&arch=x86_64 [Could not resolve host: mirrors.fedoraproject.org]
Error: Failed to download metadata for repo 'fedora': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-35&arch=x86_64 [Could not resolve host: mirrors.fedoraproject.org]
Error: package upgrade on guest OS failed: exit status 1
Describe the results you expected:
I would expect it to use the hosts DNS server settings to resolve
Additional information you deem important (e.g. issue happens only occasionally):
This might be related to an issue with WSL https://github.com/microsoft/WSL/issues/3438 It is important not for me to be able to access the Internet on any WSL instance I always need to config the resolve.conf to have the appropriate DNS nameservers
Output of podman version:
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman socket: Get "http://d/v4.1.0/libpod/_ping": dial unix /wsl$/Fedora34/run/podman/podman.sock: connect: A socket operation encountered a dead network.
Output of podman info --debug:
Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman socket: Get "http://d/v4.1.0/libpod/_ping": dial unix /wsl$/Fedora34/run/podman/podman.sock: connect: A socket operation encountered a dead network.
P
Package info (e.g. output of rpm -q podman or apt list podman):
N/A
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)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.): The ability to update the resolve conf as part of the init would be appreciated or to run init wait for it to fail fix the VM manually and then continue the setup
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 33 (7 by maintainers)
Here’s my workaround, it requires a separate WSL instance (I used ubuntu) and you’ll need to run the commands as root so the owner bits are properly saved.
cdto directory where you downloaded the fedora tar filemkdir /fed && tar xfJ fedora-35-x86_64.tar.xz -C /fed- Extract the tarcd /fedecho -e "nameserver 1.1.1.1\n" >./etc/resolv.conf- Use cloudflare DNS (replace IP as required)echo -e "[network]\ngenerateResolvConf = false\n" >./etc/wsl.conf- Tell WSL not to mess with our DNStar cfJ /fedora.tar.xz *- Rebuild the tarmv /fedora.tar.xz <windows_folder>- Put it where podman can get at itpodman machine init --image-path fedora.tar.xz- init podmanAnd here’s a scripty version of it. May contain typos.
I found an alternative way - for those urgently needing to get Podman to run.
and if you get as lucky as me …
Now to get on with the next step 😉
This should in principle always work as the podman “disk” is a vhd and the container concept is portable - but I am not responsible if you break something!
Podman machine does a number of customization steps, so thats why you are receiving this error. Until we have a simpler override mechanism, what might work as a temporary hack, is you could modify the rootfs that we start from:
https://github.com/fedora-cloud/docker-brew-fedora/blob/35/x86_64/fedora-35-x86_64.tar.xz
If you add your custom resolv.conf and a /etc/wsl.conf to the tarball with
then you pass that the new tar.xz to
podman machine init --image-path custom.tar.xzI’m not completely sure if those files will survive, but worth a try.