devsandbox 0.11.0

Manage devcontainer-style sandboxes on docker, podman, or Apple container — many throwaway instances per repo from one TOML config.
---
title: Port a devcontainer.json
description: Turn an existing devcontainer.json into a devsandbox config.
order: 7
icon: file-code
tags: [devcontainers, migration]
related: [services, caches, parallel-agents]
---

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

## The problem

Your repo already has a `.devcontainer/devcontainer.json`. `devsandboxes.toml` uses the same property names in TOML, so most of it moves over line by line. `folder` says which repo the sandbox is for, and compose services become `[services.*]`.

<AgentPromptLink />

## Config

```jsonc title=".devcontainer/devcontainer.json (before)"
{
  "name": "web",
  "image": "mcr.microsoft.com/devcontainers/typescript-node:22",
  "features": {
    "ghcr.io/devcontainers/features/github-cli:1": {}
  },
  "forwardPorts": [3000],
  "remoteUser": "node",
  "postCreateCommand": "npm ci",
  "customizations": {
    "vscode": { "extensions": ["dbaeumer.vscode-eslint"] }
  }
}
```

```toml title="devsandboxes.toml (after)"
[sandbox.web]                      # the table key replaces `name`
folder = "../web"                  # the repo; devsandboxes.toml lives outside it
image = "mcr.microsoft.com/devcontainers/typescript-node:22"
forwardPorts = [3000]
remoteUser = "node"
postCreateCommand = "npm ci"
customizations.vscode.extensions = ["dbaeumer.vscode-eslint"]

[sandbox.web.features]
"ghcr.io/devcontainers/features/github-cli:1" = {}
```

## Try it

```bash
devsandbox ls                  # validates the config
devsandbox run web
```

## How it works

devsandbox never reads the `devcontainer.json`. `ls` errors on unknown keys and `run` warns about ignored ones.

| devcontainer.json | devsandboxes.toml | notes |
|---|---|---|
| the file's location | `folder` | required by `run` |
| `name` | the table key | ignored |
| `build.*` | `build = { dockerfile, context, … }` | paths relative to the config dir |
| `updateRemoteUserUID` | same | `false` means `identity = "image"` |
| `hostRequirements.gpu` | same | other `hostRequirements` ignored |
| `onCreateCommand` … `postAttachCommand` | same | tables run in order |
| `customizations.vscode.settings` | repo `.vscode/settings.json` | ignored |
| `appPort`, `portsAttributes` | `devsandbox port web 3000` | ignored |
| `runArgs`, `capAdd`, `securityOpt` | none | ignored |
| `dockerComposeFile`, `service` | `[services.*]` + `services` | error |

Other properties carry over as they are. The full list is in the [config reference](/docs/config#implemented-devcontainer-properties). Compose services become [services](/examples/services) the sandbox reaches by name.

## Agent instructions

<AgentPrompt prompt="port-a-devcontainer" />