docker / for-mac

Bug reports for Docker Desktop for Mac
https://www.docker.com/products/docker#/mac
2.43k stars 118 forks source link

Docker Desktop for Mac installation misses /etc/hosts entry: host.docker.internal #4442

Open alan-czajkowski opened 4 years ago

alan-czajkowski commented 4 years ago

Expected behavior

Docker Desktop adds the following entry to /etc/hosts:

127.0.0.1   host.docker.internal

similarly to how it already adds the following entry:

# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1   kubernetes.docker.internal

Actual behavior

Docker Desktop does not add the host.docker.internal entry into /etc/hosts.

Information

Diagnostic logs

{
  "id": "182B98A2-F31A-44AE-A89A-E7266F83451E",
  "date": "2020-04-11 02:28:41.877003 +0000 UTC",
  "os": "macOS 10.14.6",
  "os_label": "osx/10.14.x",
  "app_version": "2.2.0.5",
  "app_channel": "stable",
  "engine_version": "19.03.8",
  "compose_version": "1.25.4",
  "kubernetes_version": "v1.15.5",
  "credhelper_version": "0.6.3",
  "notary_version": "0.6.1",
  "vpnkit_version": "ea9dbeaf887f5dad8391f4a34d127501fb6bbf64",
  "hyperkit_version": "v0.20190802-4-g97f091"
}

Steps to reproduce the behavior

docker-robott commented 4 years ago

Issues go stale after 90 days of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

alan-czajkowski commented 4 years ago

/remove-lifecycle stale

ulo commented 4 years ago

I have the same problem! This works on Docker Desktop Windows but not on Docker Desktop Mac. Would be great to be able to use host.docker.internal for an OS independent development...

docker-robott commented 3 years ago

Issues go stale after 90 days of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

alan-czajkowski commented 3 years ago

/lifecycle frozen

falnyr commented 3 years ago

@alan-czajkowski Not sure about your use case but I just tested a container in Docker for Mac and although the host.docker.internal is not present in /etc/hosts the actual address is resolved.

When I curl host.docker.internal I'm getting a response from the webserver running on the host.

tcarrio commented 2 years ago

I think another issue here is that services that expose themselves specifically to 127.0.0.1 are not going to be accessible when accessed by the IP resolved via host.docker.internal without the /etc/hosts entry.

In my case, I have a local mysql server instance that is exposed on localhost only and cannot be accessed by the service running in docker hitting host.docker.internal without the /etc/hosts entry.

tandriamil commented 1 year ago

Hello, I encountered the same problem: we are working on Windows and Mac OSes and have inconsistencies due to host.docker.internal being accessible on Windows, but not on macOS. Looking at /etc/hosts though, there is an alias defined for kubernetes.docker.internal instead.

calrizien commented 1 year ago

I had the same problem on MacOS

GollyJer commented 1 year ago

Same problem. Wish we could use the same settings on Windows and Mac.

jhult commented 1 year ago

Some related reading at https://github.com/docker/for-mac/issues/2965