devsandbox 0.5.0

Manage devcontainer-style sandboxes on docker, podman, or Apple container — many throwaway instances per repo from one TOML config.
---
title: devcontainer Features
description: Add Node, Rust or the GitHub CLI to any image, in TOML.
order: 8
icon: package
tags: [devcontainers, images]
related: [port-a-devcontainer, caches, vscode]
---

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

## The problem

Every repo needs a slightly different toolchain: this one Node 22, that one Rust, all of them `gh`. Maintaining a Dockerfile per repo for that is busywork, and the devcontainer ecosystem already packages each tool as a **Feature**.

devsandbox installs Features natively, without the devcontainer CLI: list them under `features` with the same references and options as in `devcontainer.json`.

<AgentPrompt
  goal="Look at my current devsandbox config and suggest devcontainer Features where they make sense."
  steps={[
    'Find toolchains installed by Dockerfiles, lifecycle commands or heavy images that an official Feature could provide. List each suggestion and what it replaces, and apply only the ones I pick.',
  ]}
  verify={[]}
/>

## Config

```toml title="config.toml"
[template.base]
image = "mcr.microsoft.com/devcontainers/base:ubuntu"   # plain Ubuntu, no toolchain
features = { "ghcr.io/devcontainers/features/github-cli:1" = true }   # gh everywhere, default options

[sandbox.web]
extends = "base"
folder = "../web"
features = { "ghcr.io/devcontainers/features/node:1" = "22" }   # a string sets the `version` option

[sandbox.api]
extends = "base"
folder = "../api"
features = { "ghcr.io/devcontainers/features/rust:1" = { profile = "minimal" } }   # or a table of options
```

## Try it

```bash
devsandbox run web                     # fetches the Features, builds the image
devsandbox run web --name fix-login    # its own worktree, same toolchain
devsandbox exec fix-login node --version   # v22.x
devsandbox exec fix-login gh --version
```

- `--name`: the instance name.

Change a Feature, say node `"20"`, and apply it:

```bash
devsandbox rebuild fix-login           # drifted: recreated with node 20
```

## How it works

- Features are baked into an image derived from `image` or `build`, `devsandbox-img-<sandbox>-feat`; OCI references only ([`features`](/docs/config#implemented-devcontainer-properties)).
- `features` tables merge key by key under `extends`: `web` gets gh and node ([templates](/docs/config#templates-and-extends)).
- `= false` skips a Feature, e.g. one inherited from a template.
- Adding, removing or changing a Feature makes existing instances drift; `devsandbox rebuild` applies it ([drift](/docs/config#drift)).