buildkit: Rootless mode doesn't work on Google Container-Optimized OS kernel (CONFIG_SECURITY_CHROMIUMOS_NO_UNPRIVILEGED_UNSAFE_MOUNTS?)
~ $ cat Dockerfile
FROM alpine
~ $ export BUILDKIT_HOST=tcp://127.0.0.1:1234
~ $ buildctl b --frontend dockerfile.v0 --local context=. --local dockerfile=.
[+] Building 0.0s (2/2) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 49B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
error: failed to solve: rpc error: code = Unknown desc = failed to read dockerfile: failed to mount /home/user/.local/tmp/buildkit-mount290620720: [{Type:bind Source:/home/user/.local/share/buildkit/runc-native/snapshots/snapshots/1 Options:[rbind ro]}]: operation not permitted
But unshare -rm mount works 🤔
~ $ unshare -mr
buildkitd-649b4db5d4-jskbq:/home/user# mount --rbind -o ro /home/user/.local/share/buildkit/runc-native/snapshots/snapshots/1 /home/user/.local/tmp/buildkit-mount710693070
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
***************************************** Ready <none> 19m v1.12.5-gke.5 ************** Container-Optimized OS from Google 4.14.89+ docker://17.3.2
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
selector:
matchLabels:
app: buildkitd
template:
metadata:
labels:
app: buildkitd
annotations:
container.apparmor.security.beta.kubernetes.io/buildkitd: unconfined
container.seccomp.security.alpha.kubernetes.io/buildkitd: unconfined
spec:
containers:
- image: moby/buildkit:v0.4.0-rootless@sha256:3877d091e65429f59919ed5591aaeb863b1889a5314bdfdba5ff9c0dfb2f3ed0
args:
- --addr
- tcp://0.0.0.0:1234
- --oci-worker-no-process-sandbox
name: buildkitd
ports:
- containerPort: 1234
---
apiVersion: v1
kind: Service
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
ports:
- port: 1234
protocol: TCP
selector:
app: buildkitd
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 25 (16 by maintainers)
Commits related to this issue
- iaas: add a `workers-2` to test out rootless From https://github.com/moby/buildkit/issues/879, it seems like GKE's container-optimized instances introduce trouble for running rootless containers - ad... — committed to concourse/hush-house by deleted user 5 years ago
- hh: replace `worker-tracing` by `worker-ubuntu` Continuing with the explorations on how the use of rootless containers might be affected by `gke`'s COS base images (see https://github.com/moby/buildk... — committed to concourse/hush-house by deleted user 5 years ago
- Ubuntu nodes support buildkit without --privileged, as documented in https://github.com/moby/buildkit/issues/879 — committed to Yolean/ystack by solsson 5 years ago
- iaas: add a `workers-2` to test out rootless From https://github.com/moby/buildkit/issues/879, it seems like GKE's container-optimized instances introduce trouble for running rootless containers - ad... — committed to concourse/infrastructure by deleted user 5 years ago
- fix: use rootful buildkit to avoiding https://github.com/moby/buildkit/issues/879 — committed to LeoAlex0/dualoj-judge by LeoAlex0 2 years ago
Yes, latest GKE with
cos_containerdimage. I got fully functional rootless buildkit with resource definitions from examples/kubernetes with only added a emptyDir/hostPath volumeMount for/home/user/.local/share/buildkit.Yes, and that’s the problem - default volumes are mounted with
nosuid,nodevflags, which causePermission deniederror trying to remount this volume without this flags. See details in an excellent investigation from @bcressey there in linked bottlerocket issue.Not only the issue in snapshotter
@ei-grad On GCOS kernel? 👀
Using an idea from https://github.com/bottlerocket-os/bottlerocket/issues/1934 I added an emptyDir volume to
/home/user/.local/share/buildkitand it worked.v0.4.0-rootless (both
overlayandnative; both w/ and w/oprivileged) works with GKE Ubuntu nodes (kernel4.15.0-1026-gcp #27-Ubuntu, kube v1.11.7-gke.4, Ubuntu 18.04.1, docker://17.3.2).Seems an issue on Google COS.
No, even
v0.3.0-rootlessw/securityContext: privilegeddoes not work now.This is rather likely to be a regression in GKE, although I don’t have any evidence that
v0.3.0-rootlesshad been working on GKE.