Skip to content

Commit f2c41e1

Browse files
authored
Merge pull request moby#3097 from AkihiroSuda/gcos-rootless
rootless: support Google Container-Optimized OS (Fix ` Options:[rbind ro]}]: operation not permitted` errors)
2 parents c46a5a5 + b36488e commit f2c41e1

File tree

6 files changed

+66
-4
lines changed

6 files changed

+66
-4
lines changed

docs/rootless.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@ Rootless mode allows running BuildKit daemon as a non-root user.
44

55
## Distribution-specific hint
66
Using Ubuntu kernel is recommended.
7+
### Container-Optimized OS from Google
8+
Make sure to have an `emptyDir` volume below:
9+
```yaml
10+
spec:
11+
containers:
12+
- name: buildkitd
13+
volumeMounts:
14+
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
15+
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
16+
# as it is mounted with `nosuid,nodev`.
17+
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
18+
- mountPath: /home/user/.local/share/buildkit
19+
name: buildkitd
20+
volumes:
21+
- name: buildkitd
22+
emptyDir: {}
23+
```
24+
25+
See also the [example manifests](#Kubernetes).
26+
27+
<details>
28+
<summary>Old distributions</summary>
29+
30+
<p>
731
832
### Debian GNU/Linux 10
933
Add `kernel.unprivileged_userns_clone=1` to `/etc/sysctl.conf` (or `/etc/sysctl.d`) and run `sudo sysctl -p`.
@@ -16,8 +40,8 @@ This step is not needed for RHEL/CentOS 8 and later.
1640
### Fedora, before kernel 5.13
1741
You may have to disable SELinux, or run BuildKit with `--oci-worker-snapshotter=fuse-overlayfs`.
1842

19-
### Container-Optimized OS from Google
20-
:warning: Currently unsupported. See [#879](https://github.com/moby/buildkit/issues/879).
43+
</p>
44+
</details>
2145

2246
## Known limitations
2347
* Using the `overlayfs` snapshotter requires kernel >= 5.11 or Ubuntu kernel.
@@ -77,6 +101,9 @@ $ rootlesskit buildkitd --oci-worker-snapshotter=native
77101
### Error related to `newuidmap` or `/etc/subuid`
78102
See https://rootlesscontaine.rs/getting-started/common/subuid/
79103

104+
### Error `Options:[rbind ro]}]: operation not permitted`
105+
Make sure to mount an `emptyDir` volume on `/home/user/.local/share/buildkit` .
106+
80107
## Containerized deployment
81108

82109
### Kubernetes

examples/kubernetes/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ This directory contains Kubernetes manifests for `Pod`, `Deployment` (with `Serv
77
* `Job`: good if you don't want to have daemon pods
88

99
Using Rootless mode (`*.rootless.yaml`) is recommended because Rootless mode image is executed as non-root user (UID 1000) and doesn't need `securityContext.privileged`.
10-
11-
:warning: Rootless mode may not work on some host kernels. See [`../../docs/rootless.md`](../../docs/rootless.md).
10+
See [`../../docs/rootless.md`](../../docs/rootless.md).
1211

1312
See also ["Building Images Efficiently And Securely On Kubernetes With BuildKit" (KubeCon EU 2019)](https://kccnceu19.sched.com/event/MPX5).
1413

examples/kubernetes/deployment+service.rootless.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@ spec:
6363
- name: certs
6464
readOnly: true
6565
mountPath: /certs
66+
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
67+
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
68+
# as it is mounted with `nosuid,nodev`.
69+
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
70+
- mountPath: /home/user/.local/share/buildkit
71+
name: buildkitd
6672
volumes:
6773
# buildkit-daemon-certs must contain ca.pem, cert.pem, and key.pem
6874
- name: certs
6975
secret:
7076
secretName: buildkit-daemon-certs
77+
- name: buildkitd
78+
emptyDir: {}
7179
---
7280
apiVersion: v1
7381
kind: Service

examples/kubernetes/job.rootless.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@ spec:
5252
- name: workspace
5353
readOnly: true
5454
mountPath: /workspace
55+
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
56+
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
57+
# as it is mounted with `nosuid,nodev`.
58+
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
59+
- mountPath: /home/user/.local/share/buildkit
60+
name: buildkitd
5561
# To push the image, you also need to create `~/.docker/config.json` secret
5662
# and set $DOCKER_CONFIG to `/path/to/.docker` directory.
5763
volumes:
5864
- name: workspace
5965
emptyDir: {}
66+
- name: buildkitd
67+
emptyDir: {}

examples/kubernetes/pod.rootless.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ spec:
3434
# To change UID/GID, you need to rebuild the image
3535
runAsUser: 1000
3636
runAsGroup: 1000
37+
volumeMounts:
38+
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
39+
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
40+
# as it is mounted with `nosuid,nodev`.
41+
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
42+
- mountPath: /home/user/.local/share/buildkit
43+
name: buildkitd
44+
volumes:
45+
- name: buildkitd
46+
emptyDir: {}

examples/kubernetes/statefulset.rootless.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,13 @@ spec:
4747
# To change UID/GID, you need to rebuild the image
4848
runAsUser: 1000
4949
runAsGroup: 1000
50+
volumeMounts:
51+
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
52+
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
53+
# as it is mounted with `nosuid,nodev`.
54+
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
55+
- mountPath: /home/user/.local/share/buildkit
56+
name: buildkitd
57+
volumes:
58+
- name: buildkitd
59+
emptyDir: {}

0 commit comments

Comments
 (0)