How to access host port from docker container

To have a docker container connect to a port on the host machine, you need to use the IP of the docker bridge. Note that localhost will not work from within a docker container. That localhost (or is the localhost of the container.

The shared localhost port is accessible via docker0. It’s usually

You can find it with this command:

ip addr show docker0 | grep -Po 'inet \K[\d.]+'
Last modified: April 28, 2021
© 2024