---
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
goal="Port the devcontainer.json of my repo at <repo path> to a sandbox in my devsandbox devsandboxes.toml."
steps={[
'Read <repo path>/.devcontainer/devcontainer.json and any Dockerfile or docker-compose.yml it references; do not modify them.',
'Add a `[sandbox.<sandbox name>]` with `folder` pointing at <repo path> and copy the implemented properties over; rebase `build` paths onto the config dir.',
'Drop the properties the config-toml-spec lists as ignored and tell me what each did; turn compose services into `[services.*]` listed in `services`.',
]}
verify={[
'Run `devsandbox -C <config dir> run <sandbox name>` and report any `warning:` lines.',
]}
/>