moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
8.03k stars 1.12k forks source link

rootless: permission denied (`[rootlesskit:child ] error: failed to share mount point: /: permission denied`) #2441

Open fgiannetti opened 2 years ago

fgiannetti commented 2 years ago

Hello all! I am trying to execute rootless buildkit inside a Kubernetes container (using Argo workflow). I followed the doc instructions but i am getting the error:

could not connect to unix:///run/user/1000/buildkit/buildkitd.sock after 10 trials ========== log ========== [rootlesskit:child ] error: failed to share mount point: /: permission denied [rootlesskit:parent] error: child exited: exit status 1 sh: can't kill pid 8: No such process

The k8s nodes are using Ubuntu 18.04.4 LTS with Kernel 4.15.0-112-generic

I cant figure out what is the problem. Is there a external configuration that I am missing?

Here is the yaml that i am using:

apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: name: buildkit-test spec: entrypoint: image templates:

Thanks very much!

fgiannetti commented 2 years ago

Additional info: Running the same yaml in a local minikube cluster, it works fine!

AkihiroSuda commented 2 years ago

https://github.com/moby/buildkit/blob/0279989d7f0df0fc98a4f32b4c6650dde2a42107/examples/buildctl-daemonless/buildctl-daemonless.sh#L15

Please try changing rootlesskit to rootlesskit --propagation=rslave

fgiannetti commented 2 years ago

Hello Akiro! Thanks for your answer!

I get the same error, but with an aditional warning message: "The host root filesystem is mounted as \"master:700\". Setting child propagation to \"rslave\" is not supported."

Is a Warning but could this be the reason for the error?

Thanks again!

unckleg commented 2 years ago

Same error's here. Running on GKE.

unckleg commented 2 years ago

@fgiannetti

I've got it working with:

securityContext:
  privileged: true

So try adding it to your task:

  args:
    - build
    - --frontend
    - dockerfile.v0
    - --local
    - context=.
    - --local
    - dockerfile=.
    - --output
    - type=image,name=hub.docker/myRepo:0.0.8-BK,push=true
  securityContext:
    privileged: true
fgiannetti commented 2 years ago

@unckleg Adding that config now it is working! Thank you so much!

leeweisberger commented 2 years ago

I am running into the same error running on GKE (ubuntu based image, both containerd and docker) with moby/buildkit:v0.10.0-rootless and buildctl-daemonless.sh. I don't want to add privileged: true to my pod and the instructions claim that this should work without privileged.

Any other thoughts here? Can we please reopen this issue? This last hurdle is blocking adoption of BuildKit for us!

unckleg commented 2 years ago

@leeweisberger What executor are you using on top of BuildKit? Please share a wider context 👀

leeweisberger commented 2 years ago

For anyone else who gets this. make sure you disable apparmour. Once I did that, the issue went away!

AbimbolaE commented 1 year ago

Instead of disabling apparmour entirely as @leeweisberger suggested, a more secure alternative would be to add the unconfined apparmour profile to your buildkitd container

For example ...

spec:
  replicas: 1
  selector:
    matchLabels:
      app: buildkitd
  template:
    metadata:
      labels:
        app: buildkitd
      annotations:
        container.apparmor.security.beta.kubernetes.io/buildkitd: unconfined  # <-- here

References