2

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?

top 5 comments
sorted by: hot top controversial new old
[-] trabiko@alien.top 1 points 11 months ago

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.

[-] not-the-real-chopin@alien.top 1 points 11 months ago

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.

[-] isleepbad@alien.top 1 points 11 months ago

No that's not correct. You don't need to be in host mode to access the local LAN.

[-] maximus459@alien.top 1 points 11 months ago

This, mnn.. but if you want to know who a reply is from you should be on the hike Ian right?

[-] thekrautboy@alien.top 1 points 11 months ago

I know that in order to reach the local LAN I should configure the network mode to "host", is that correct?

No, that has nothing to do with that.

In that case am I still able to reach the other containers running in the default bridge network?

No, using network_mode host makes it more complicated to also reach other containers on the same Docker host.

Why not ask /r/Docker and read the Docker documentation?

this post was submitted on 23 Oct 2023
2 points (100.0% liked)

Self-Hosted Main

502 readers
1 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

For Example

We welcome posts that include suggestions for good self-hosted alternatives to popular online services, how they are better, or how they give back control of your data. Also include hints and tips for less technical readers.

Useful Lists

founded 1 year ago
MODERATORS