feat(sandbox): separate bind mounts for browser containers (#16230)

* feat(sandbox): add separate browser.binds config for browser containers

Allow configuring bind mounts independently for browser containers via
sandbox.browser.binds. When set, browser containers use browser-specific
binds instead of inheriting docker.binds. Falls back to docker.binds
when browser.binds is not configured for backwards compatibility.

Closes #14614

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(sandbox): honor empty browser binds override (#16230) (thanks @seheepeak)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
seheepeak
2026-02-14 23:27:41 +09:00
committed by GitHub
parent 302dafbe1a
commit cb9a5e1cb9
9 changed files with 104 additions and 1 deletions

View File

@@ -106,9 +106,13 @@ export async function ensureSandboxBrowser(params: {
const state = await dockerContainerState(containerName);
if (!state.exists) {
await ensureSandboxBrowserImage(params.cfg.browser.image ?? DEFAULT_SANDBOX_BROWSER_IMAGE);
const browserDockerCfg =
params.cfg.browser.binds !== undefined
? { ...params.cfg.docker, network: "bridge", binds: params.cfg.browser.binds }
: { ...params.cfg.docker, network: "bridge" };
const args = buildSandboxCreateArgs({
name: containerName,
cfg: { ...params.cfg.docker, network: "bridge" },
cfg: browserDockerCfg,
scopeKey: params.scopeKey,
labels: { "openclaw.sandboxBrowser": "1" },
});

View File

@@ -88,6 +88,9 @@ export function resolveSandboxBrowserConfig(params: {
}): SandboxBrowserConfig {
const agentBrowser = params.scope === "shared" ? undefined : params.agentBrowser;
const globalBrowser = params.globalBrowser;
const binds = [...(globalBrowser?.binds ?? []), ...(agentBrowser?.binds ?? [])];
// Treat `binds: []` as an explicit override, so it can disable `docker.binds` for the browser container.
const bindsConfigured = globalBrowser?.binds !== undefined || agentBrowser?.binds !== undefined;
return {
enabled: agentBrowser?.enabled ?? globalBrowser?.enabled ?? false,
image: agentBrowser?.image ?? globalBrowser?.image ?? DEFAULT_SANDBOX_BROWSER_IMAGE,
@@ -107,6 +110,7 @@ export function resolveSandboxBrowserConfig(params: {
agentBrowser?.autoStartTimeoutMs ??
globalBrowser?.autoStartTimeoutMs ??
DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS,
binds: bindsConfigured ? binds : undefined,
};
}

View File

@@ -40,6 +40,7 @@ export type SandboxBrowserConfig = {
allowHostControl: boolean;
autoStart: boolean;
autoStartTimeoutMs: number;
binds?: string[];
};
export type SandboxPruneConfig = {