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?
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
I think it is possible.
Try communicate with the host's<ip:port>
ip: useip addr
or something similar to get the one of eth0,not the one of docker0
port:the one you assigned to the app
To make the process easier,perhaps turn selinux and firewall down when you try.