Skip to content

Commit 4a074f3

Browse files
committed
docs(sandbox): simplify mount examples
1 parent f37da23 commit 4a074f3

5 files changed

Lines changed: 66 additions & 64 deletions

File tree

‎crates/openshell-driver-docker/README.md‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,13 @@ Docker `volume` mounts may include `subpath`. Mount targets must be absolute
6262
container paths and must not replace the workspace root (`/sandbox`) or overlap
6363
OpenShell supervisor files, auth material, TLS material, or `/run/netns`.
6464

65-
Example NFS usage relies on Docker's named-volume support rather than a host
66-
bind:
65+
Example named-volume usage:
6766

6867
```shell
69-
docker volume create \
70-
--driver local \
71-
--opt type=nfs \
72-
--opt o=addr=10.0.0.10,rw,nfsvers=4 \
73-
--opt device=:/exports/work \
74-
work-nfs
68+
docker volume create openshell-work
7569

7670
openshell sandbox create \
77-
--driver-config-json '{"docker":{"mounts":[{"type":"volume","source":"work-nfs","target":"/sandbox/work"}]}}' \
71+
--driver-config-json '{"docker":{"mounts":[{"type":"volume","source":"openshell-work","target":"/sandbox/work"}]}}' \
7872
-- claude
7973
```
8074

‎crates/openshell-driver-podman/README.md‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,13 @@ config. Mount targets must be absolute container paths and must not replace the
7878
workspace root (`/sandbox`) or overlap OpenShell supervisor files, auth
7979
material, TLS material, or `/run/netns`.
8080

81-
Example NFS usage relies on Podman's named-volume support rather than a host
82-
bind:
81+
Example named-volume usage:
8382

8483
```shell
85-
podman volume create \
86-
--opt type=nfs \
87-
--opt o=addr=10.0.0.10,rw,nfsvers=4 \
88-
--opt device=:/exports/work \
89-
work-nfs
84+
podman volume create openshell-work
9085

9186
openshell sandbox create \
92-
--driver-config-json '{"podman":{"mounts":[{"type":"volume","source":"work-nfs","target":"/sandbox/work"}]}}' \
87+
--driver-config-json '{"podman":{"mounts":[{"type":"volume","source":"openshell-work","target":"/sandbox/work"}]}}' \
9388
-- claude
9489
```
9590

‎docs/reference/sandbox-compute-drivers.mdx‎

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,30 @@ For GPU-backed Docker sandboxes, configure Docker CDI before starting the gatewa
7676

7777
Docker driver config accepts user-supplied `volume` and `tmpfs` mounts. It also
7878
accepts `bind` mounts when `[openshell.drivers.docker]` sets
79-
`enable_bind_mounts = true` in `gateway.toml`. Host bind mounts expose gateway
80-
host paths to sandbox requests, so they are disabled by default. Host bind
81-
mounts are unsafe: they put gateway-host filesystem state directly inside the
82-
sandbox and can negate OpenShell controls such as workspace isolation and
83-
filesystem policy. Enable them only for trusted local workflows where you
84-
understand and accept that loss of isolation. Image mounts are not accepted in
79+
`enable_bind_mounts = true` in `gateway.toml`. Image mounts are not accepted in
8580
Docker sandbox driver config.
8681
Docker's [storage documentation](https://docs.docker.com/engine/storage/)
8782
documents container storage mounts as volumes, bind mounts, tmpfs mounts, and
8883
named pipes.
8984

90-
Use a `volume` mount for existing Docker named volumes. This includes NFS
91-
volumes created with Docker's local volume driver:
85+
Use a `volume` mount for existing Docker named volumes:
9286

9387
```shell
94-
docker volume create \
95-
--driver local \
96-
--opt type=nfs \
97-
--opt o=addr=10.0.0.10,rw,nfsvers=4 \
98-
--opt device=:/exports/work \
99-
work-nfs
88+
docker volume create openshell-work
10089

10190
openshell sandbox create \
102-
--driver-config-json '{"docker":{"mounts":[{"type":"volume","source":"work-nfs","target":"/sandbox/work","read_only":false}]}}' \
91+
--driver-config-json '{"docker":{"mounts":[{"type":"volume","source":"openshell-work","target":"/sandbox/work","read_only":false}]}}' \
10392
-- claude
10493
```
10594

106-
Use a `bind` mount only after enabling it in the Docker driver table. Treat
107-
this setting as an unsafe operator override:
95+
<Warning>
96+
Bind mounts share gateway-host filesystem resources with the sandbox. They may
97+
be considered insecure because they can negate OpenShell controls such as
98+
workspace isolation and filesystem policy. Use them only when you understand and
99+
accept that loss of isolation.
100+
</Warning>
101+
102+
Use a `bind` mount only after enabling it in the Docker driver table:
108103

109104
```toml
110105
[openshell.drivers.docker]
@@ -145,39 +140,26 @@ On macOS with `podman machine`, the driver uses gvproxy's host-loopback IP, `192
145140

146141
Podman driver config accepts user-supplied `volume`, `tmpfs`, and `image`
147142
mounts. It also accepts `bind` mounts when `[openshell.drivers.podman]` sets
148-
`enable_bind_mounts = true` in `gateway.toml`. Host bind mounts expose gateway
149-
host paths to sandbox requests, so they are disabled by default. Host bind
150-
mounts are unsafe: they put gateway-host filesystem state directly inside the
151-
sandbox and can negate OpenShell controls such as workspace isolation and
152-
filesystem policy. Enable them only for trusted local workflows where you
153-
understand and accept that loss of isolation.
143+
`enable_bind_mounts = true` in `gateway.toml`.
154144

155-
Use a `volume` mount for existing Podman named volumes. This includes NFS
156-
volumes created with Podman's local volume driver:
145+
Use a `volume` mount for existing Podman named volumes:
157146

158147
```shell
159-
podman volume create \
160-
--opt type=nfs \
161-
--opt o=addr=10.0.0.10,rw,nfsvers=4 \
162-
--opt device=:/exports/work \
163-
work-nfs
148+
podman volume create openshell-work
164149

165150
openshell sandbox create \
166-
--driver-config-json '{"podman":{"mounts":[{"type":"volume","source":"work-nfs","target":"/sandbox/work","read_only":false}]}}' \
151+
--driver-config-json '{"podman":{"mounts":[{"type":"volume","source":"openshell-work","target":"/sandbox/work","read_only":false}]}}' \
167152
-- claude
168153
```
169154

170-
Use an `image` mount to mount an OCI image filesystem through Podman's
171-
image-volume API:
172-
173-
```shell
174-
openshell sandbox create \
175-
--driver-config-json '{"podman":{"mounts":[{"type":"image","source":"ghcr.io/acme/tools:latest","target":"/opt/tools"}]}}' \
176-
-- claude
177-
```
155+
<Warning>
156+
Bind mounts share gateway-host filesystem resources with the sandbox. They may
157+
be considered insecure because they can negate OpenShell controls such as
158+
workspace isolation and filesystem policy. Use them only when you understand and
159+
accept that loss of isolation.
160+
</Warning>
178161

179-
Use a `bind` mount only after enabling it in the Podman driver table. Treat
180-
this setting as an unsafe operator override:
162+
Use a `bind` mount only after enabling it in the Podman driver table:
181163

182164
```toml
183165
[openshell.drivers.podman]

‎e2e/rust/tests/driver_config_volume.rs‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![cfg(feature = "e2e-local-container-driver")]
55

66
use std::fs;
7+
use std::io::Write;
78
use std::os::unix::fs::PermissionsExt;
89
use std::process::Output;
910
use std::time::{SystemTime, UNIX_EPOCH};
@@ -93,8 +94,10 @@ async fn sandbox_mounts_enabled_driver_config_bind() {
9394
.expect("create bind mount host dir");
9495
fs::set_permissions(host_dir.path(), fs::Permissions::from_mode(0o777))
9596
.expect("make bind mount host dir writable by sandbox user");
96-
fs::write(host_dir.path().join("input.txt"), "host-bind-ok")
97-
.expect("seed bind mount host dir");
97+
let input_path = host_dir.path().join("input.txt");
98+
fs::write(&input_path, "host-bind-ok").expect("seed bind mount host dir");
99+
fs::set_permissions(&input_path, fs::Permissions::from_mode(0o666))
100+
.expect("make bind mount input readable by sandbox user");
98101

99102
let driver_config = driver_config_mount_json(
100103
&driver,
@@ -105,8 +108,14 @@ async fn sandbox_mounts_enabled_driver_config_bind() {
105108
"read_only": false
106109
}),
107110
);
111+
// Host bind mounts are explicitly unsafe: this test validates driver mount
112+
// wiring, not Landlock enforcement over Docker Desktop's fakeowner mounts.
113+
let policy = write_bind_mount_policy().expect("write bind mount policy");
114+
let policy_path = policy.path().to_str().expect("policy path must be utf-8");
108115
let mut sandbox = SandboxGuard::create(&[
109116
"--no-keep",
117+
"--policy",
118+
policy_path,
110119
"--driver-config-json",
111120
&driver_config,
112121
"--",
@@ -129,6 +138,27 @@ async fn sandbox_mounts_enabled_driver_config_bind() {
129138
assert_eq!(output, "sandbox-bind-ok");
130139
}
131140

141+
fn write_bind_mount_policy() -> Result<tempfile::NamedTempFile, String> {
142+
let mut file =
143+
tempfile::NamedTempFile::new().map_err(|err| format!("create bind policy: {err}"))?;
144+
file.write_all(
145+
br#"version: 1
146+
147+
filesystem_policy:
148+
include_workdir: false
149+
150+
landlock:
151+
compatibility: best_effort
152+
153+
process:
154+
run_as_user: sandbox
155+
run_as_group: sandbox
156+
"#,
157+
)
158+
.map_err(|err| format!("write bind policy: {err}"))?;
159+
Ok(file)
160+
}
161+
132162
fn seed_volume(volume: &VolumeGuard) -> Result<(), String> {
133163
run_engine(
134164
&volume.engine,

‎e2e/with-podman-gateway.sh‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,6 @@ resolve_podman_supervisor_image() {
252252
ensure_podman_supervisor_image() {
253253
local image=$1
254254

255-
if podman_cmd image exists "${image}" 2>/dev/null; then
256-
return 0
257-
fi
258-
259255
if [ "${image}" = "openshell/supervisor:dev" ] \
260256
&& [ -z "${OPENSHELL_SUPERVISOR_IMAGE:-}" ] \
261257
&& [ -z "${CI:-}" ]; then
@@ -270,6 +266,10 @@ ensure_podman_supervisor_image() {
270266
exit 2
271267
fi
272268

269+
if podman_cmd image exists "${image}" 2>/dev/null; then
270+
return 0
271+
fi
272+
273273
echo "Pulling Podman supervisor image ${image}..."
274274
if podman_cmd pull "${image}"; then
275275
return 0
@@ -342,6 +342,7 @@ HOST_PORT=$(e2e_pick_port)
342342
HEALTH_PORT=$(e2e_pick_port)
343343
STATE_DIR="${WORKDIR}/state"
344344
mkdir -p "${STATE_DIR}"
345+
export XDG_STATE_HOME="${STATE_DIR}"
345346
JWT_DIR="${STATE_DIR}/jwt"
346347

347348
E2E_NAMESPACE="e2e-podman-$$-${HOST_PORT}"

0 commit comments

Comments
 (0)