I have a docker container as part of docker-compose that should reach other containers but as well a server running in my local network.
(the docker container is a monitoring service)
I know that in order to reach the local LAN I should configure the network mode to “host”, is that correct? In that case am I still able to reach the other containers running in the default bridge network?
You should be able to reach local network running in bridge mode, here’s a test from my local server pinging the laptop, executed in a docker container
root@dalek:/# ping -c1 192.168.8.167 PING 192.168.8.167 (192.168.8.167): 56 data bytes 64 bytes from 192.168.8.167: seq=0 ttl=64 time=0.440 ms \--- 192.168.8.167 ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max = 0.440/0.440/0.440 ms root@dalek:/# ip route get 192.168.8.167 192.168.8.167 dev eno1 src 192.168.8.136
Host mode exposes the listening ports of the container as they were services on the machine, so iptables doesn’t do any mangling of traffic where to send connection to port XY to which container.
Thanks, it must have been some other problem. I’m able to reach my local network from within the docker container. I even found that the docker container is using the host DNS configuration.
I configured pi.hole as DNS server in the host machine and the docker container is using it too.