Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Devcontainer?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/jacobley-devcontainer)
---
name: devcontainer
description: DevContainer runtimes, CLI tools, and version parity with Dagger
---
# Skill: DevContainer
> VS Code docs: [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers)
The DevContainer is defined in [`.devcontainer/`](../../../.devcontainer/) and is the canonical development environment for this repo. Opening a worktree in VS Code triggers a prompt to reopen in the container, which builds the image and mounts the main checkout and its sibling `<main>-worktrees/` folder at the same absolute paths they have on the host. See the [worktrees skill](../worktrees/SKILL.md) for the layout and the `nx-cache` sidecar.
Files live on the host, so they survive container rebuilds. Claude Code config is shared across containers via `CLAUDE_CONFIG_DIR`, and its `settings.json` and `CLAUDE.md` with other repos' devcontainers via `.claude-shared/` (see the [worktrees skill](../worktrees/SKILL.md#layout)).
**Goal:** every runtime, CLI tool, and script needed for development is available as soon as the container starts, with no manual setup. If you add a tool, add it to the image.
---
## What the DevContainer provides
| Tool | Purpose | Notes |
|---------|--------------------|-------|
| Node.js | JS runtime | Image pinned by digest via `ARG NODE_IMAGE` in `Dockerfile` |
| pnpm | Package management | Version pinned via `ARG PNPM_VERSION`. Installed outside the lockfile, so `minimumReleaseAge` can't hold it back: only bump to a release at least 7 days old |
| Go | Golang runtime, for Dagger and Go projects (e.g. `tools/constant-consistent-hash/go`) | Image pinned by digest via `ARG GO_IMAGE`, at the Go minor of the pinned Dagger engine (`GolangVersion` in its `engine/distconsts/consts.go`); also installs `gopls`, and the `golangci-lint` release at `ARG GOLANGCI_LINT_VERSION`, checked against the release's checksums |
| Rust | Rust runtime and WASM builds, for Rust projects (e.g. `tools/constant-consistent-hash/rust`) | Image pinned by digest via `ARG RUST_IMAGE`, with `rustfmt`, `clippy`, `llvm-tools-preview`, `rust-analyzer`, `rust-src` and the `wasm32-unknown-unknown` target, plus `cargo-llvm-cov` and `wasm-bindgen-cli` at `ARG CARGO_LLVM_COV_VERSION` and `ARG WASM_BINDGEN_VERSION`. Adds about 950 MB to the image. No `rust-toolchain.toml`, which would let rustup download a different toolchain on its own |
| Python | Ad-hoc scripting (no projects use it) | Version pinned via `ARG PYTHON_VERSION`, prebuilt by [python-build-standalone](https://github.com/astral-sh/python-build-standalone) at release `ARG PYTHON_BUILD`: only bump to a release at least 7 days old. Not mirrored in Dagger |
| Dagger CLI | Mirror CI execution locally | Version pinned via `ARG DAGGER_VERSION`. `postCreateCommand` runs `dagger-develop` beside `pnpm install`, so editors can resolve `dagger/main.go`. A failure only warns: the container still starts |
| Playwright browser libraries | System libraries for Chromium, Firefox and WebKit | Version pinned via `ARG PLAYWRIGHT_VERSION`. The browsers themselves are downloaded by the `playwright-install` target to `PLAYWRIGHT_BROWSERS_PATH`, shared between worktrees |
| Docker | `docker-outside-of-docker` devcontainer feature | Shares the host Docker socket — required to run Dagger |
| Valkey | Real service for tests that need one (e.g. `tools/lease-cache`) | `valkey` sidecar in `docker-compose.yml`, reachable at `valkey:6379`. One per worktree, with nothing persisted. Pinned by digest |
| Postgres | Real database for tests that need one | `postgres` sidecar in `docker-compose.yml`, reachable at `DATABASE_URL` (`postgres://postgres:postgres@postgres:5432/postgres`, a fixed local-only password). One per worktree, held in memory (`tmpfs`) so a restart starts from empty; dev data comes from scripts, never from what a database happens to hold. `fsync`, `synchronous_commit` and `full_page_writes` are off for speed (only a machine or VM crash can corrupt it, and nothing is kept anyway), and `max_connections` is 500 for parallel test runs. Pinned by digest |
| AWS Emulator | A local server for AWS APIs, for tests that need one (e.g. the DynamoDB store of `tools/idempotency-keys`) | `aws-emulator` at `/opt/aws-emulator/bin`, version pinned via `ARG AWS_EMULATOR_VERSION` (a release at least 7 days old), its package's signature checked against AWS's key fingerprint. Not a sidecar: it serves only HTTPS, with a certificate made at each start for `localhost` and `127.0.0.1`, so each test run starts its own through `tools/aws-emulator-launch`, which reads the endpoint, CA and credentials from its startup line. `EMULATOR_TELEMETRY=off`. Adds about 950 MB to the image |
| Postgres client tools | `psql`, and `pg_dump` for schema snapshots | `postgresql-client-<major>` from the PostgreSQL apt repository, at `ARG POSTGRES_MAJOR`. `pg_dump` must be at least the server's major version |
| HTTPS ingress | `https://<worktree>.<repo>.localhost` to port 5173 of this worktree's container | The workspace's service (`leyman` in leyman; `apply` names a fork's after it) joins the external `local-ingress` network, with caddy-docker-proxy labels naming its host and port. Sidecars stay off it, so `postgres` and `valkey` resolve to this worktree's own. `initialize.sh` starts the shared ingress ([`tools/local-ingress`](../../../tools/local-ingress/README.md)) and writes `REPO_NAME` and `WORKTREE_NAME` (from `.devcontainer/names.sh`), which are also in the container's environment. An optional `TUNNEL_HOST` in `.devcontainer/.env` survives the rewrite and is served beside the `.localhost` name ([tunnels](../../../tools/local-ingress/README.md#tunnels)). Local only: Dagger has no equivalent |
| GitHub CLI | `gh`, for PRs and issues | Version pinned via `ARG GH_VERSION` (a release at least 7 days old). Not mirrored in Dagger. Its login lives in `GH_CONFIG_DIR` under `.shared/`, so `gh auth login` once, in any container, covers every worktree and rebuild. With no keyring in the container, the token is stored in plain text there: prefer a fine-grained token |
| Nx, Biome, ESLint | Workspace tooling | From `leyman/main/node_modules/.bin`, on `PATH` via `remoteEnv` after `postCreateCommand` runs `pnpm install` |
| Nx daemon | Off | `NX_DAEMON=false` in `remoteEnv`, as in CI: set explicitly rather than left to Nx's own default, which already turns it off in Docker ([nrwl/nx#14126](https://github.com/nrwl/nx/issues/14126)). It would keep the project graph in memory between `nx` commands, but cost memory per worktree and hold state that can go stale for no measured gain. `nx-daemon-bench unknown-error` reruns the measurement (for instance after an Nx upgrade); it starts and stops a daemon itself. It found no difference beyond noise on Nx 24.0.5, with 14 cores and 23 GB visible to the container (2026-11-19; 20 hyperfine runs per side after 3 warmups, in two rounds off, on, on, off; 6 for `verify`). Medians with the daemon against without: `nx show projects` 0.81 s against 0.86 s, an uncached `unknown-error` build (88 tasks) 4.13 s against 4.09 s, the same build with every task a cache hit 3.15 s against 3.07 s (2.93 s against 2.96 s with its `dist` deleted, so restored), a warm `verify` 42.7 s against 41.0 s. Outputs that already match the cache are left in place either way. The daemon holds about 230 to 280 MB, or 290 to 350 MB with its child process |
| hyperfine | Benchmarks, such as `nx-daemon-bench` | Version pinned via `ARG HYPERFINE_VERSION` (a release at least 7 days old), only the binary from the release's `.deb`. Not mirrored in Dagger |
| Git's `core.fsmonitor` | Off in the container only, via `GIT_CONFIG_*` in `remoteEnv` | The shared `.git/config` may set it for the host. Git refuses it on this mount, which it sees as remote, and warns on every command |
| Local Scripts | Complicated combos of tasks in a single command | `<worktree>/scripts/commands` is on `PATH` (via `remoteEnv`), exposing these shortcuts |
## Dockerfile layout
The `Dockerfile` is multi-stage, so a version bump rebuilds only what it must (bumping Node rebuilds in seconds, not minutes):
- Each tool (Node, Go and `gopls`, golangci-lint, Rust, pnpm, Python, `gh`, Dagger) is fetched in its own stage, at the path it has in the final image. The final stage copies them in **last**, after the slow system installs (Postgres client, Playwright's libraries, Homebrew, oh-my-zsh, Claude).
- Declare each `ARG` in the stage that uses it, right before its first use: a changed `ARG` reruns every `RUN` after its declaration in that stage. `ARG`s before the first `FROM` are only for `FROM` lines (the base image, Node and Go).
- Playwright's system libraries: the `playwright-deps` stage lists the packages `install-deps` would install, and the final stage installs that list. The install reruns only when the list changes.
- Node is only the `node` binary, at `/usr/local/bin/node` (no npm). Version-free paths like this one keep editor settings unchanged across bumps.
- An image pinned with `FROM name:tag@sha256:...` is stored with no tag, which Docker and OrbStack report as dangling. `postCreateCommand` runs `.devcontainer/tag-pinned-images.sh` to tag them.
---
## Rebuilding
**Rebuild Container** in VS Code deletes the workspace container (`leyman`, not the sidecars) and starts a new one. VS Code doesn't wait for Docker to finish deleting the old container before running `docker compose up --no-recreate`. If the delete is still under way, compose finds the old container, tries to start it and fails:
```
Error response from daemon: container is marked for removal and cannot be started
```
**Retry** then works, because the delete has finished by the time you click it. To confirm it was this race, list the container's events: the old container's `destroy` lands after the failed `up` in the log.
```sh
docker events --since 10m --until 0s --filter type=container \
--filter "label=devcontainer.local_folder=$(git rev-parse --show-toplevel)" \
--format '{{.Time}} {{.Action}} {{.Actor.ID}}' | grep -E ' (kill|destroy|create|start) '
```
Dev Containers 0.385.0 fixed an earlier form of this race, where `docker rm -f` itself failed ([microsoft/vscode-remote-release#6509](https://github.com/microsoft/vscode-remote-release/issues/6509)). It still happens when the delete takes long enough ([microsoft/vscode-remote-release#11967](https://github.com/microsoft/vscode-remote-release/issues/11967)). Seen on OrbStack: 19 seconds from kill to delete, while two other repos' devcontainers were rebuilt in the same minute. How long a delete takes depends on how busy Docker is and on how much the container wrote to its own filesystem, which Docker deletes with it. Idle, 2.4 GB written as 30,000 files deletes in about a second, and 9.6 GB in under 3. The container keeps what grows elsewhere, which also keeps those caches across rebuilds:
- pnpm's metadata cache (`pnpm_config_cache_dir`) and Go's build and module caches (`GOCACHE`, `GOMODCACHE`) are in `.shared/`, set in `docker-compose.yml`. They're shared by every worktree like the pnpm store, and survive rebuilds.
- `/tmp` is a `tmpfs`, which costs nothing to delete. It's mounted `exec`: Docker's default `noexec` breaks Nx, which loads its native binding from a copy in `/tmp` (and fails with `WorkspaceContext is not a constructor`), and `go test`, which runs its binaries from there. It's in memory, so it's cleared whenever the container stops, and what's written there counts against Docker's memory.
`~/.vscode-server` (VS Code's server and extensions) and `~/.local/share/claude` (Claude Code's auto-updated versions) still hold about 1.5 GB. Moving them would take a named volume per worktree, and someone would have to clean those up. To see what has grown, use `docker ps --size` and `docker diff <container>`, and move it to `.shared/` the same way. Rebuilding one devcontainer at a time also makes the race less likely.
---
## Version parity: DevContainer ↔ Dagger
The Dagger CI pipeline runs in its own container — it does **not** use the DevContainer image. Versions are specified separately in two places and must be kept in sync:
| Runtime | DevContainer | Dagger |
|---------|-------------|--------|
| Node.js | `ARG NODE_IMAGE` in `.devcontainer/Dockerfile`, the `nx-cache` and `dagger-nx-cache` images in `.devcontainer/docker-compose.yml`, and `image` in `demos/local-ingress/run` (pinned by digest, the same as `nodeImage`) | `nodeImage` tag in `dagger/main.go`, and its version as `NODE_VERSION` in `.github/workflows/ci.yml` and `comparison-report.yml`, for the scripts their jobs run on the runner (`actions/setup-node`) |
| pnpm | `ARG PNPM_VERSION` in `.devcontainer/Dockerfile` | `pnpmVersion` in `dagger/main.go` |
| Go | `ARG GO_IMAGE` in `.devcontainer/Dockerfile` | `goImage` in `dagger/main.go`. The same image, pinned by digest, at the Go minor of the pinned Dagger engine: check it when bumping Dagger |
| golangci-lint | `ARG GOLANGCI_LINT_VERSION` in `.devcontainer/Dockerfile` | `golangciLintVersion` in `dagger/main.go`, with the checksums below it. The release must be built with a Go at least the `go` directive of every `go.mod` |
| Rust | `ARG RUST_IMAGE` in `.devcontainer/Dockerfile`, and `rust-version` in the root `Cargo.toml` | `rustImage` in `dagger/main.go`. The same image, pinned by digest |
| cargo-llvm-cov | `ARG CARGO_LLVM_COV_VERSION` in `.devcontainer/Dockerfile` | `cargoLlvmCovVersion` in `dagger/main.go`, with the checksums below it |
| wasm-bindgen | `ARG WASM_BINDGEN_VERSION` in `.devcontainer/Dockerfile` | `wasmBindgenVersion` in `dagger/main.go`, with the checksums below it. Both must match the `wasm-bindgen` crate in `Cargo.lock`, and a mismatch fails the build |
| OpenTofu | `ARG TOFU_IMAGE` in `.devcontainer/Dockerfile` | `tofuImage` in `dagger/main.go`. The same image, pinned by digest: only its `tofu` binary is copied in |
| dagger | `ARG DAGGER_VERSION` in `.devcontainer/Dockerfile` | `engineVersion` in `dagger/dagger.json`, and `DAGGER_VERSION` in `.github/workflows/ci.yml`, `test-uncached.yml`, `comparison-report.yml` and `adoption-audits.yml` |
| Debian | base image tag in `.devcontainer/Dockerfile` (`debian13`) | `debianImage` in `dagger/main.go`, and the `nodeImage` and `goImage` variants (`trixie` = Debian 13) |
| Playwright | `ARG PLAYWRIGHT_VERSION` in `.devcontainer/Dockerfile` | `playwrightVersion` and the `playwrightImage` tag in `dagger/main.go`. All must match `playwright` in `pnpm-workspace.yaml`. Dagger doesn't install browsers: tests connect to a `playwright` service (`run-server` in the official image, pinned by digest) at `PW_TEST_CONNECT_WS_ENDPOINT`, where the devcontainer launches them locally |
| Valkey | `valkey` service image in `.devcontainer/docker-compose.yml` | `valkeyImage` in `dagger/main.go`. Both pinned by digest, and the service is bound under the same hostname (`valkey`) |
| Postgres | `postgres` service image and `command` settings in `.devcontainer/docker-compose.yml` | `postgresImage` and `postgresService` in `dagger/main.go`. Both pinned by digest, bound under the same hostname (`postgres`), with the same `DATABASE_URL` |
| Postgres client tools | `ARG POSTGRES_MAJOR` in `.devcontainer/Dockerfile` | `postgresMajor` in `dagger/main.go`. Must match the Postgres image's major version |
| AWS Emulator | `ARG AWS_EMULATOR_VERSION` and the signing key's fingerprint in `.devcontainer/Dockerfile` | `awsEmulatorVersion` and `awsEmulatorKeyFingerprint` in `dagger/main.go`. Both download the Debian package and check its signature, with `EMULATOR_TELEMETRY=off` |
**When upgrading a runtime version, update all locations in the table above.** After bumping a digest-pinned image in a Dockerfile, run `docker rmi <image>:<old-tag>` once no worktree needs the old version: it keeps its tag, so nothing flags it for cleanup. This deletes the image rather than only untagging it, because Docker drops an image along with its last tag. A worktree still on the old pin downloads it again on its next rebuild. The [`check-parity`](../nx-tasks-reference/SKILL.md#check-parity) target fails on any pair that differs, naming both, locally and in CI's `test` job. It can't check the Go minor against the Dagger engine, or the Postgres `command` settings and service hostnames, so check those by hand. Every image is pinned by digest, so a bump is always a deliberate edit; get the new one with `docker buildx imagetools inspect <image>:<tag>`. Dagger downloads `cargo-llvm-cov` and `wasm-bindgen` as prebuilt binaries where the devcontainer compiles them, so a bump also needs both architectures' checksums: `sha256sum` of each release's `*-unknown-linux-musl.tar.gz`. An image is outside the lockfile too, so only pin a digest at least 7 days old. Rebuilds move a tag to a newer digest, so if the tag's current digest is too new, find an older one in the history of `repos/<image>/remote/<tag>.md` in [docker-library/repo-info](https://github.com/docker-library/repo-info), or wait. A mismatch means `dagger-test` runs under a different Node/pnpm version than local development — bugs that only reproduce in CI are a common symptom.