-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Pull request moby/moby#40007 implemented a "magic" host-gateway
value to allow users to add host.docker.internal
to /etc/hosts
in containers, mapping it to the gateway IP address (the IP address itself can be configured in the daemon configuration).
With this feature, users running dockerd on Linux can get parity with Docker for Mac / Docker for Windows to have host.docker.internal
resolve inside containers.
Currently, this option is "opt-in" on Linux; containers will not be able to resolve host.docker.internal
unless they are created with --add-host host.docker.internal:host-gateway
Proposal
Users may want to have the host.docker.internal
host added automatically for every container created (similar to how it's currently added automatically on Docker Desktop (Docker for Mac / Docker for Windows).
I suggest to:
- add an option to the CLI configuration file (
~/.docker/config.json
) that allows configuring a default (set of) custom hosts for new containers - possibly (t.b.d.) an environment variable to configure this
The configuration option could potentially be used by the Docker Desktop team, as a replacement for the current (proprietary) implementation; doing so would make the implementation on Linux and Docker Desktop identical (which would make it less confusing).