Ping sensors do not work in Docker container

Hello,

I have set up two wake on LAN and one ping device presence sensor in my configuration, but they do not seem to ever turn on, even if the devices are online.
Is there a setting I need to enable to allow pings from the container?

I’m using Portainer, Host networking and HA 2021.11.5.

Thanks!

1 Like

Wake-on-LAN magic packets are mutlicast packets, which require special rules set up for it to be routed between the internal docker network and the host network.

Not for me. Using WOL in docker with no issues with host networking…

I’m the magic packets work, just the pings don’t get in/out.

Thank you. I’ll look into this

Would you know what roles need to be put in place?

Sorry, I have avoided containers and VMs for that reason.
I tried first with a docker solution, but multicast WOL and multicast Discovery was an issue and having to make it being routed from first the docker network to the host network and then to a second VLAN was too much for me, so jumped the low fence. :slight_smile:

1 Like

Its a bit funny if your WOL packets get through, but not the pings.
That sounds like a misconfigured firewall instead.

1 Like

I’ve done some digging but I’ve not yet found a fix.
The host system can ping fine.

Well, ping packets are actually using a icmp protocol and not the standard tcp or udp protocol, that are used most often for network communication, so maybe you are missing a routing configuration for those kind of packets.

Pings work on Home Assistant OS, and Home Assistant Supervised. Both run all the parts of Home Assistant in multiple Docker containers, so I can confidently state that pings absolutely work in docker containers.

1 Like

Yep, plain Ping works for me in a Container install as well.

Hi all,
Thanks for your replies.
It’s “great” to hear that it’s my fault!

I’ll ask over at a Docker fourm. Hopefully they have an idea.

Update!
Running chmod u+s /bin/ping inside of the container fixes this issue.
Not sure if if persists between image updates, though. I have a feeling it doesn’t.

Hurray!

Good that it worked, but it doesn’t really make sense to me as HA is running as root inside the container.
Oh well…

Note that it definitely doesn’t survive an image update.

I’ll do some more testing.

Yup. That’s the fix - I re pulled the image, it stopped working, ran the command, it started working. How odd. I’ll have to see if I can make an issue.

Mystery thickens…
I ran in debug mode and ping doesn’t even use the executable for me

DEBUG (SyncWorker_14) [homeassistant.components.ping] Using icmplib in privileged=True mode

To be clear, I do not run the container in privileged mode…

Maybe some selinux gizmo? By experience, if something doesn’t make sense permission-wise, selinux is the first thing to check :wink:

How odd.

I’ve made a issue here. https://github.com/home-assistant/docker-base/issues/164

It turns out I was running in privileged mode - left over from testing, but the fix still works with it off.

Update,
After a chat on Discord, It seems that Portainer mangles containers and that was part of the root cause for this issue.
I’m now moving to Compose files.

@Koying, thanks for your help in this issue!