question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add host.docker.internal to ContainerMetadataFetcher list of approved hosts

See original GitHub issue

ContainerMetadataFetcher currently allows three hosts for container metadata endpoints: 169.254.170.2, localhost, and 127.0.0.1. However, neither localhost or 127.0.0.1 represent the local docker host. Instead, the host’s localhost is reachable as host.docker.internal (docs). On Linux, the workaround is to use --network host, but on Mac and Windows this doesn’t work (the docker network is always isolated from the host).

host.docker.internal should be added to ContainerMetadataFetcher’s list of approved hosts, so that a custom metadata endpoint for testing can be run on the host rather than needing to be run in another container.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
benkehoecommented, Jul 26, 2022

I have solved this for now in my aws-export-credentials tool by providing an IMDSv2-compatible endpoint; the IMDS endpoint is not subject to the same host checks. I think this issue still stands, though.

0reactions
benkehoecommented, Nov 23, 2022

I should note that in addition to aws-export-credentials I made a single-purpose implementation in Go: imds-credential-server

But I’d love to see this host supported in all SDKs

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to connect to the Docker host from inside a ...
As of Docker version 18.03, you can use the host.docker.internal hostname to connect to your Docker host from inside a Docker container.
Read more >
What is the equivalent of --add-host=host.docker.internal ...
The actual Docker Compose equivalent is achieved by appending the same string to the extra_hosts parameters (#Doc) as:
Read more >
Host.docker.internal seems doesnt work with CI/CD Github ...
Hello everyone, im new here and using docker. We are developing an app and we need to use a subgraph, so the community...
Read more >
Traefik Docker Documentation
try a lookup of host.docker.internal; if the lookup was unsuccessful, ... be provided as an extra_host to the Traefik container, using the --add-host...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found