How does hass in docker map it's ports such as 8123 to ports of host?

just like the images above, I find that it doesn’t use the port mapping of docker, because the “port” column of homeassistant is None.

And I want to develop an integration that communicates with other PCs and I must find ways to map port of host to homeassistant which runs in the docker.

Is there anyone know about this ?

It’s because it’s using host mode networking.

2 Likes

Oh, thanks! I viewed it’ conifg.v2.json and I found “HostMode” yesterday. I didn’t know what’s meaning, and I just went to docker.com to view it’s doc thanks to your reply. But I am still not sure how the container compete with host for the port. Is it just like a program ? For example, if I want to connect container through ssh, then how does the container which homeassistant is in get the 22 port rather than host? I’a a novice at docker. T_T

There’s two things at play:

  1. Port mapping, where you explicitly say expose port X
  2. Host mode, where the container is effectively connected to the host’s network interface

In (1) you have to pick what ports to expose, and what port they’re mapped to inside the container.

In (2) the software in the container just tries to open the port, eg port 22. If the port isn’t already in use then it can do that.

1 Like

Oh,thanks for your reply. I think I got it completely. Love you, :smiling_face_with_three_hearts: