On Mac and Windows, it is possible to use host.docker.internal
(Docker 18.03+) inside a container.
Is there one for Linux that will work out of the box without passing environment variables or extracting it using various CLI commands?
For Linux systems, you can – starting from major version 20.04
of the Docker engine – now also communicate with the host via host.docker.internal
. This won't work automatically, but you need to provide the following run flag:
--add-host=host.docker.internal:host-gateway
See the answer here: How to access host port from docker container
See also this answer below to add to a docker-compose file - What is the Linux equivalent of "host.docker.internal"?