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

Cannot resolve a host from a local hosts entry #1245

Closed
jhollmannk opened this issue Jan 14, 2022 · 4 comments
Closed

Cannot resolve a host from a local hosts entry #1245

jhollmannk opened this issue Jan 14, 2022 · 4 comments
Labels
Milestone

Comments

@jhollmannk
Copy link

Rancher Desktop Version

0.7.1

Rancher Desktop K8s Version

1.22.5

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Enterprise 21H2

What CPU architecture are you using?

x64

Windows User Only

No response

Actual Behavior

An entry in the local hosts file cannot be resolved inside a running container depending on the resolve method of the linux running inside the container.

Steps to Reproduce

Start RancherDesktop with dockerd as the container runtime.
Make an entry in your local c:\Windows\system32\drivers\etc\hosts like
10.3.6.25 host.docker.internal
start a basic alpine:
docker run -it --rm alpine sh
In the started container shell call
ping host.docker.internal

Result

The ping fails with the message
ping: bad address 'host.docker.internal'

Expected Behavior

The ping should succeed.

Additional Information

To make things more complicated:

The command
getent hosts host.docker.internal
in the alpine container returns the expected address
10.3.6.25 host.docker.internal host.docker.internal

Additionally if you start a basic ubuntu
docker run -it --rm ubuntu sh
and install ping in the running shell
apt update
apt install iputils-ping
The ping comand described above works out of the box.

So this is an issue with how a hostname is resolved in the running linux. I raise this issue because DockerDesktop does not have this problem with the alpine container.

@jhollmannk jhollmannk added the kind/bug Something isn't working label Jan 14, 2022
@jhollmannk jhollmannk changed the title Cannot resove a host from a local hosts entry Cannot resolve a host from a local hosts entry Jan 14, 2022
@gaktive gaktive added this to the v1.0.1 milestone Jan 24, 2022
@gaktive
Copy link
Contributor

gaktive commented Feb 8, 2022

@mook-as, does #1302 address this?

@mook-as
Copy link
Contributor

mook-as commented Feb 9, 2022

I believe that #1302 does address this:

  • We run a dnsmasq, which does read /etc/hosts (that was generated from the Windows one at C:\Windows\system32\drivers\etc\hosts).
  • That means it picks up the entries and responds as a DNS server to them.

(Tested by adding a host on the Windows side, and running an alpine container — even though that host name isn't listed in /etc/hosts in the container, it works fine.)

@jandubois
Copy link
Member

Sounds like this should be fixed then. Please open a new issue if you still have problems resolving DNS with the next release!

@akhilesh-d
Copy link

akhilesh-d commented Jan 9, 2025

@jandubois This issue reopens in 1.17 (I upgraded from 1.16 to 1.17 , in 1.16 it was working ok)

Container Engine :dockerd ( moby)

Environment details
OS: Windows 11 23H2
WSL version: 2.4.8.0
Kernel version: 5.15.167.4-1

.wslconfig

[experimental]
bestEffortDnsParsing=true

=============
I have added following line in c:\Windows\System32\drivers\etc\hosts

172.26.80.1 rd-local

--Steps to reproduce --

start a basic alpine:
docker run -it --rm alpine sh
In the started container shell call
ping rd-local


C:>docker run -it --rm alpine sh
/ #
/ #
/ # ping rd-local
ping: bad address 'rd-local'
/ # ping www.google.com
PING www.google.com (142.250.194.4): 56 data bytes
64 bytes from 142.250.194.4: seq=0 ttl=63 time=0.404 ms
64 bytes from 142.250.194.4: seq=1 ttl=63 time=1.268 ms
^C
--- www.google.com ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.404/0.836/1.268 ms
/ #

=====
C:>ping rd-local

Pinging rd-local [172.26.80.1] with 32 bytes of data:
Reply from 172.26.80.1: bytes=32 time<1ms TTL=128

Ping statistics for 172.26.80.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Control-C
^C
C:>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants