devsandbox 0.10.0

Manage devcontainer-style sandboxes on docker, podman, or Apple container — many throwaway instances per repo from one TOML config.
---
title: Browsers with their sandbox
description: Run Playwright, Puppeteer or Electron in a sandbox without turning the browser's own sandbox off.
order: 8
icon: globe-lock
tags: [browsers, testing]
related: [parallel-agents, port-forwarding, port-a-devcontainer]
---

import AgentPrompt from '../../components/AgentPrompt.astro';
import AgentPromptLink from '../../components/AgentPromptLink.astro';

## The problem

Chromium's sandbox needs user namespaces, which docker's default seccomp profile blocks, so people add `--no-sandbox` everywhere. devsandbox makes the browser sandbox work where it can, checks each new container, and tells the tools which case they are in.

<AgentPromptLink />

## Try it

No config needed. `run` and `devsandbox inspect web` print what the check found:

```text title="OUTPUT"
browser sandbox: on
```

Playwright turns Chromium's sandbox off by default, so launch it like this:

```js title="playwright"
const browser = await chromium.launch({
  chromiumSandbox: !!process.env.DEVSANDBOX_BROWSER_SANDBOX,
  executablePath: process.env.DEVSANDBOX_CHROME,
});
```

## How it works

- Docker sandboxes get docker's default seccomp profile plus user namespaces. Podman's default already allows them.
- Where the check passes, every `exec` gets `DEVSANDBOX_BROWSER_SANDBOX=1`. Where it fails, the tools' own sandbox-off variables are set instead.
- Where execs run as root, `DEVSANDBOX_CHROME` points at a wrapper that starts the browser as a non-root user.
- [`userns = false`](/docs/config#devsandbox-extras) keeps docker's default profile, with the browser sandbox off.

## Agent instructions

<AgentPrompt
  goal="Make the browser tests of my repo at <repo path> keep Chromium's sandbox wherever my devsandbox sandbox <sandbox name> supports it."
  steps={[
    'Find where the repo launches a browser. For Playwright, pass `chromiumSandbox: !!process.env.DEVSANDBOX_BROWSER_SANDBOX` and `executablePath: process.env.DEVSANDBOX_CHROME`.',
    'Remove any hand-added `--no-sandbox` flag. Do not change the sandbox\'s `userns`.',
  ]}
  verify={[
    'Run `devsandbox -C <config dir> run <sandbox name>`, report its `browser sandbox:` line, then run the browser tests in the instance and report what happened.',
  ]}
/>