I can't run ping if i am not the root user. In my case I am running a program that is running ping as the apache user. The service is started with a uid of 0 however the apache user is not able to run ping.
an easy fix is chmod u+s /bin/ping however I feel like this should be something that makes it's way upstream.
To reproduce you can do build this dockerfile https://github.com/michaeljs1990/phpipam/blob/dockerfile/Dockerfile and then exec into it make a lol.php file in the working dir and use this script.
<?php
exec('/bin/ping -c 5 -w 5 192.168.1.5 2>&1', $output);
var_dump($output);
and go go lol.php.
You need to set net.ipv4.ping_group_range on your host to enable unprivileged icmp sockets.
see for example: https://sturmflut.github.io/linux/ubuntu/2015/01/17/unprivileged-icmp-sockets-on-linux/
Alternatively, you can install the iputils package to use the non-BusyBox ping which has the correct permissions you need.
Most helpful comment
Alternatively, you can install the
iputilspackage to use the non-BusyBoxpingwhich has the correct permissions you need.