docs icon indicating copy to clipboard operation
docs copied to clipboard

Accessing host.docker.internal from a container

Open kaisersly opened this issue 9 months ago • 3 comments
trafficstars

Is this a docs issue?

  • [x] My issue is about the documentation content or website

Type of issue

I can't find what I'm looking for

Description

I have a service running on my host (python -m http.server 8111), I can't reach it from a container using host.docker.internal (curl http://host.docker.internal:8111 -> curl: (7) Failed to connect to host.docker.internal port 8111 after 0 ms: Couldn't connect to server).

To achieve this, I had to create two configuration files :

~/.config/systemd/user/docker.service.d/override.conf
[Service]
Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_DISABLE_HOST_LOOPBACK=false"

~/.config/docker/daemon.json
{ "host-gateway-ip": "10.0.2.2" }

Location

https://docs.docker.com/engine/security/rootless/

Suggestion

It would be great if the problem and the solution appeared directly on the rootless page.

kaisersly avatar Feb 07 '25 10:02 kaisersly

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.

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

/lifecycle stale

docker-robot[bot] avatar May 12 '25 01:05 docker-robot[bot]

/remove-lifecycle stale

kaisersly avatar May 12 '25 07:05 kaisersly

/lifecycle frozen

kaisersly avatar May 12 '25 07:05 kaisersly