Docker Community Forums

Share and learn in the Docker community.

Container port (using host network) is only accessible via docker host itself

I’m trying to add krambox/homekit2mqtt:latest to my setup, but the issue I run into is that container’s internal webhost (running on http port 51888) is not accessible anywhere but the docker host server.

To get the mDNS working well, container is setup with --net=host, while up and running I can see the data being picked up by homekit, but I can’t access the webhost besides over the SSH connection to the machine running docker.

In case I set the container to use bridge network, port is working and accessible everywhere, host network breaks that.

As alternative I’m trying to see if I can setup avahi to rebroadcast the mDNS data, but I’m really interested to figuring out what could be causing an issue in my setup so that I know how to fix it in case it happens again in the future.

Thank you,

Ok, found the cause of my issue. Distribution of linux I’ve used had iptables (firewall) preinstalled. I had to explicitly allow traffic to the ports used by containers attached to host network.

Here is the command which ended up solving the issue in my case. it is included as an example:
iptables --append INPUT --protocol tcp --dport 51888 --jump ACCEPT