rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.94k stars 281 forks source link

Not able to connect to host from within docker container using host.docker.internal #7611

Open jochenhebbrecht opened 1 week ago

jochenhebbrecht commented 1 week ago

Actual Behavior

When trying to do a DNS lookup of the hostname host.docker.internal, a faulty IP address is being returned

Steps to Reproduce

Result

The 172.17.0.1 is not the correct IP. This is not the IP of the host machine. If I rerun the whole exercise but without:

        extra_hosts:
            - "host.docker.internal:host-gateway"

and I try to do a curl again, I actually get to the correct IP. Unfortunately, these lines are in our Docker compose file because we have a shared configuration with Linux users

Expected Behavior

When resolving host.docker.internal, a DNS lookup should return the correct IP address of the hostmachine

Additional Information

This is working perfectly fine with Docker Desktop. We ran into this issue as we switched to Rancher Desktop

Rancher Desktop Version

1.16.0

Rancher Desktop K8s Version

N/A

Which container engine are you using?

moby (docker cli)

What operating system are you using?

macOS

Operating System / Build Version

macOS Sequioa 15.0.1

What CPU architecture are you using?

arm64 (Apple Silicon)

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

No response

Nino-K commented 5 days ago

This issue may arise because Rancher Desktop does not recognize the special variable host-gateway. We have an issue to address this here. In the meantime, a quick workaround is to replace the special variable with an IP address."

jochenhebbrecht commented 4 days ago

@Nino-K thanks for coming back to me on this one. This explains indeed the behaviour we noticed