I am wondering if is it possible to connect to an app on local host from Docker container.
I run two Docker container which are connected to each other via link
option. But how can I connect one of the containers to the local host?
Yes, use docker run --network=container:<container-id>
--network='container:': reuse another container's network stack
This let you run a container sharing the same network interface (then localhost) from another container.
Alternatively, you can use the host
mode to give your containers the same network ips that the host has (including localhost). docker run --network=host
:
--network= 'host': use the Docker host network stack
Docs: https://docs.docker.com/engine/reference/run/#name-name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With