Originally published on kuryzhev.cloud
A new engineer joins on Monday. By Tuesday afternoon they are still comparing python --version output with a teammate, installing the wrong Node, and asking which README section is stale. Devcontainer onboarding with uv and mise replaces that with a clone and a single "Reopen in Container".
Short answer: put tool versions in a committed mise.toml, keep Python dependencies in pyproject.toml and uv.lock, and let a small postCreateCommand script install mise and run uv sync --locked. It fits teams of two or more who share a repo and a mix of laptops. It is overkill for a solo project and a poor fit for GPU-heavy or macOS-native work (see the last tip).
Keep devcontainer.json thin and put versions in mise.toml
The container should describe the OS and mounts; the toolchain should live in a file that CI and laptops can read too. If Python and Node versions sit inside devcontainer.json, people outside the container (and your CI) drift away from them. A mise.toml at the repo root is the single source for both.
Start with this file. The versions follow current stable cycles (Python 3.15, Node.js 26 LTS). Pin exact patch versions if you want fully reproducible builds.
# mise.toml
[tools]
python = "3.15"
node = "26"
uv = "latest" # pin an exact version once the team agrees on one
[env]
_.path = [".venv/bin"] # uv's virtualenv is on PATH after `uv sync`
[tasks.bootstrap]
description = "Install locked dependencies"
run = "uv sync --locked"
[tasks.test]
run = "uv run --locked pytest -q" # --locked: fail instead of silently re-locking
Docs: mise and uv. Check the mise docs for exact setting names, since they change between releases.
Install mise in a bootstrap script, not in forty lines of JSON
One idempotent shell script beats a chain of && in postCreateCommand. It can be read, linted with shellcheck, and run by hand when something breaks. The devcontainer file stays short.
// .devcontainer/devcontainer.json (the spec allows comments)
{
"name": "platform-tools",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", // verify the current tag on the registry
"remoteUser": "vscode",
"containerEnv": { "UV_LINK_MODE": "copy" },
"mounts": [
"source=uv-cache,target=/home/vscode/.cache/uv,type=volume",
"source=mise-data,target=/home/vscode/.local/share/mise,type=volume"
],
"postCreateCommand": "bash .devcontainer/bootstrap.sh"
}
#!/usr/bin/env bash
# .devcontainer/bootstrap.sh
set -euo pipefail
# volume mount points missing from the image are created root-owned,
# including parent dirs; fix before installing anything
sudo chown "$(id -u):$(id -g)" ~/.cache ~/.local ~/.local/share
sudo chown -R "$(id -u):$(id -g)" ~/.cache/uv ~/.local/share/mise
export PATH="$HOME/.local/bin:$PATH"
command -v mise >/dev/null || curl -fsSL https://mise.run | sh
mise trust # trust the repo's mise.toml inside the container
mise install # python, node, uv from mise.toml
mise run bootstrap # uv sync --locked
grep -q 'mise activate' ~/.bashrc || \
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
Watch out: piping a remote script into sh is convenient but unpinned. If your security team objects, download the mise release binary at a pinned version instead, or bake it into a custom image.
Let uv own dependencies and fail loudly on drift
Use uv sync --locked in the bootstrap, never plain uv sync. With --locked, uv errors out if uv.lock no longer matches pyproject.toml. A new hire sees a clear failure instead of silently resolving different versions than everyone else.
The same applies to uv run. By default it re-locks and syncs before running, so the test task passes --locked as well.
The setting UV_LINK_MODE=copy in the config above avoids hardlink warnings when the cache volume and the workspace sit on different filesystems. This is the documented behavior. The trade-off is slightly more disk use.
Verify the result inside the container:
mise doctor # no errors about missing shims or untrusted config
mise ls # python, node, uv listed with versions from mise.toml
uv run python -V # Python 3.15.x
uv lock --check # exits 0 when uv.lock matches pyproject.toml
Cache volumes make the second rebuild cheap, but mind ownership
Mount named volumes for the uv cache and the mise data directory so rebuilds skip the downloads. The first build still pays for the image pull and tool downloads. After that, "Rebuild Container" mostly reuses what is on disk.
Watch out: when a mount target does not already exist in the image, Docker creates it, and any missing parent directories, owned by root. If the bootstrap runs as vscode without the chown lines, you get permission-denied errors under ~/.cache/uv, ~/.local/share/mise or even ~/.local/bin. That is a typical failure on a fresh machine and easy to misread as a network problem.
Volumes also persist stale state. If a tool install behaves oddly, remove the volumes (docker volume rm uv-cache mise-data) and rebuild before debugging further.
Make devcontainer onboarding a three-command README
The onboarding doc should shrink to what a human actually types. Everything else belongs in tasks, so it cannot go stale without something failing.
git clone git@github.com:your-org/your-repo.git
code your-repo # then: "Dev Containers: Reopen in Container"
mise run test # green means the environment is correct
That last command doubles as the acceptance check. If mise run test passes, the engineer has the right interpreter, the locked dependencies, and a working PATH. Add one task per recurring chore (lint, fmt, serve) and the README stops needing a "common commands" section. For more tooling patterns like this, browse kuryzhev.cloud.
Test the container in CI so it does not rot
A devcontainer nobody builds automatically breaks quietly, usually the week a new hire needs it. Build it in CI on changes to .devcontainer/, mise.toml or uv.lock, and run the same test task. The reference devcontainer CLI is documented at containers.dev.
npm install -g @devcontainers/cli
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . mise run test # non-zero exit fails the job
Expect this job to be slower than a normal unit-test run because it builds an image and installs tools. Path filters keep the cost down.
For secrets, never bake tokens into the image or mise.toml. Forward them at runtime with remoteEnv and ${localEnv:MY_TOKEN}, and keep them out of the committed files.
Know when not to use a devcontainer
A devcontainer costs RAM, disk and some file I/O speed, and it is the wrong tool for a few jobs. On Docker Desktop for macOS and Windows, bind-mounted workspaces can be noticeably slower than native, especially for large node_modules trees. Cloning into a named volume helps, but it adds a step.
Skip it in three cases:
- GPU training boxes, where passthrough setup is its own project.
- macOS or iOS toolchains that cannot run in a Linux container.
- Solo repos where
mise install && uv syncon the host is already quick.
In those cases keep mise.toml and uv.lock, which work fine on the host, and drop only the container layer.
Watch out: the container is not a security boundary for untrusted code. Mounted SSH agents, cloud credentials and the Docker socket are reachable from inside, so treat what you forward as part of your blast radius.
Top comments (0)