I have a Debian Trixie-based container where I need to ping as a non-root user. Running the image with Docker Desktop works:
$ docker run --rm -it myimage:latest ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.032 ms
^C
--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1061ms
rtt min/avg/max/mdev = 0.032/0.042/0.052/0.010 ms
However, running the same image in Dagger produces a different result:
$ dagger shell --no-mod -c 'container | from "myimage:latest" | with-exec "ping,127.0.0.1"'
▶ connect 0.5s
✔ loading type definitions 0.2s
$ container: Container! 0.0s CACHED
$ .from(address: "myimage:latest"): Container! 0.3s CACHED
▼ .withExec(args: ["ping", "127.0.0.1"]): Container! 0.1s ERROR
┃ ping: socktype: SOCK_RAW
┃ ping: socket: Operation not permitted
┃ ping: => missing cap_net_raw+p capability or setuid?
! process "ping 127.0.0.1" did not complete successfully: exit code: 2
...
This SO post suggests installing the linux-sysctl-defaults package, but this doesn't work since the config file only applies on reboot in non-containerised installations. Running sudo setcap cap_net_raw+p /usr/bin/ping does the trick, however, I'm curious whether there are better ways to make this work in Dagger, especially since ping just works with regular Docker runs.