HomeDockerHow approach a container is getting assigned its own IP address when...

How approach a container is getting assigned its own IP address when using host networking mode?

I’m operating Docker on a mini PC server with Debian that hosts various containers, 1 of which is a Home Assistant container. This particular container is operating with host networking mode, which my understanding means the container’s community stack isn’t isolated from the host so its essentially using the host community interface immediately. According to the Docker docs, it also means the container doesn’t get assigned its own IP address. However, when I run ifconfig in the Home Assistant container, I see multiple interfaces, 2 of which are:

* docker0 with an inet address of 172.17.0.1
* enp2s0 with an inet address of 192.168.1.1 (host IP address)

Additionally, when I gaze at my Pi-Hole (DNS) logs which is another container operating on the same host, I can see a bunch of queries coming from that container IP address of 172.17.0.1.

My questions are:

1. Why is the container getting assigned the IP address of 172.17.0.1? I thought in the networking host mode it shouldn’t be assigned an IP?
2. How approach the DNS queries are showing them coming from the container IP address? I suppose it makes sense since the 2 containers exist in the same docker community and it’s just making the queries from 1 container to the other, but I thought with host networking that container essentially wouldn’t exist inside that docker community.

Everything works as anticipated but I’m just trying to understand this for my own learning. Thanks!

.

Most Popular