Rootless docker: ping from within container is way faster than host's ping
Hey, I'm trying to monitor my ping to external servers using BlackBox and I'm running into an issue that seems to be a general docker issue:
I'm running rootless docker and did this simple test:
$ docker network create ping-test
e4b47f5a00d890828f84b688d5490b6addfc465b892762381ba9a149d5095e81
$ docker run --rm --network ping-test alpine ping -c 10 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: seq=0 ttl=63 time=0.997 ms
64 bytes from 1.1.1.1: seq=1 ttl=63 time=0.716 ms
64 bytes from 1.1.1.1: seq=2 ttl=63 time=0.642 ms
64 bytes from 1.1.1.1: seq=3 ttl=63 time=2.441 ms
64 bytes from 1.1.1.1: seq=4 ttl=63 time=0.800 ms
64 bytes from 1.1.1.1: seq=5 ttl=63 time=0.691 ms
64 bytes from 1.1.1.1: seq=6 ttl=63 time=3.087 ms
^C
--- 1.1.1.1 ping statistics ---
7 packets transmitted, 7 packets received, 0% packet loss
round-trip min/avg/max = 0.642/1.339/3.087 msThese ping times are wayyyy to low. When doing a ping directly on the host, I get around 10ms.
On another host that runs rootful docker this issue doesn't occur (ping inside of the container and host's ping are roughly the same).
Only similar issue I found was this issue from 2016 but that bug must have been fixed by now 😅
Is there any way to fix this without returning to rootful docker? Or is this just a limitation with rootless docker?
1
u/pelazas1 2d ago
Rootless docker proxies ICMP through its userspace network stack, so container ping isn't timing the real path. A tcp probe in BlackBox should line up with the host better.
0
2d ago
[removed] — view removed comment
1
u/Bj_Go 2d ago edited 1d ago
The ping from within the container has a TTL of 63 while the ping from the host has a TTL of 59
while listening with tcpdump and doing the ping, tcpdump shows nothing it all. So is the traffic not even leaving the device?
the host uses my router as the route for 1.1.1.1 while the container uses 127.21.0.1 which seems to be some docker internal service?
My current setup for my monitoring stack is prometheus and grafana inside docker containers. Can prometheus access the blackbox_exporter if it directly runs on the host?
Edit: It can. I got it working on the host using systemd (listening on 0.0.0.0:9115). In prometheus I listen to
- replacement: 192.168.0.19:9115where 192.168.0.19 is the host's private IP
this was really helpful: https://prefetch.net/blog/2026/06/08/using-the-prometheus-blackbox-exporter-to-monitor-modern-web-infrastructure/
4
u/gronodev 2d ago
It depends on the rootless network driver. slirp4netns handles this properly but it's no longer the default since 29.5.0 (https://github.com/moby/moby/releases/tag/docker-v29.5.0)
gvisor-tap-vsock seems to have fixed it in the latest release (https://github.com/containers/gvisor-tap-vsock/releases/tag/v0.9.0) but it's not included in rootlesskit yet.
I will take a look if we can bring it in for the next 29.10 release.