Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ping: permission denied error (are you root?) #42

Open
paolorechia opened this issue Jul 14, 2024 · 0 comments
Open

ping: permission denied error (are you root?) #42

paolorechia opened this issue Jul 14, 2024 · 0 comments

Comments

@paolorechia
Copy link

Running on WSL2 (Windows 10 + Ubuntu 22), the ping example of Chapter 4 yields a permission denied error:

daggle-envpaolo@DESKTOP-QSGRPBP:~/dev/crio/network$ sudo crictl exec -ti $B1C_ID ping 172.27.237.131
PING 172.27.237.131 (172.27.237.131): 56 data bytes
ping: permission denied (are you root?)
FATA[0000] execing command in container: command terminated with exit code 1 

One Solution:

---
metadata:
  name: busybox
image:
  image: docker.io/library/busybox:latest
args:
  - "/bin/sleep"
  - "36000"
linux:
  security_context:
    capabilities:
      add_capabilities:
        - CAP_NET_RAW

Explanation:
It actually took me over a hour to find the solution, which is why I'm sharing how I arrived at the solution, to help the next poor soul :)

  1. Busybox container image requires the CAP_NET_RAW capability (https://superuser.com/questions/1713520/why-does-busybox-ping-expect-root)
  2. When running the command sudo crictl inspect $B1C_ID | jq .info.runtimeSpec.process.capabilities, we see that CAP_NET_RAW is not included.
  3. In the cri-api repository, one can inspect the config definition to find out how to add capabilities (https://github.com/kubernetes/kubernetes/blob/46aa8959a0659e22c924bb52b38385d441715b2b/staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto#L883)

Combining these resources we can produce the solution above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant