docker / docker/docs

Accessing host.docker.internal from a container

Open
#21,986 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/engine lifecycle/frozen
Dominant language
Markdown
Stars
4.7k
Forks
8.5k
Avg merge
2d 18h
Merged PRs (30d)
108

Description

Is this a docs issue?
  • 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rootless Docker page at https://docs.docker.com/engine/security/rootless/ and review the reported host.docker.internal behavior and configuration snippets. Document the problem and the stated solution there; done means users can find guidance for reaching a host service from a rootless container.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.