Dev Containers Skill
Expert guidance on creating, configuring, and optimising containerised development environments using the Dev Container Specification. Covers devcontainer.json authoring, Features, Templates, performance, security, multi-container setups, and cloud environments.
Quick Reference Table
| Task |
Load Resource |
Key Concepts |
Create or configure a devcontainer.json |
references/core-concepts.md |
image, build, features, lifecycle hooks, customizations |
| Add tools/languages to a container |
references/features-templates.md |
Features, version pinning, installsAfter, Templates |
| Set up multi-container or Docker-in-Docker |
references/advanced-config.md |
dockerComposeFile, DinD, DooD, Kubernetes, service |
| Improve build/startup speed |
references/performance-security.md |
layer caching, named volumes, pre-built images, Virtio-fs |
| Harden container security or manage secrets |
references/performance-security.md |
remoteUser, UID mapping, SSH forwarding, secrets |
| Debug slow mounts, permission errors, credential issues |
references/troubleshooting.md |
UID/GID, bind mounts, SSH agent, postCreateCommand |
| Integrate with Codespaces or DevPod |
references/advanced-config.md |
prebuilds, providers, SSH, cloud residency |
Orchestration Protocol
Phase 1 — Classify the Task
Identify which category the user's request falls into:
- Configuration — writing or editing
devcontainer.json, Dockerfiles, Compose files
- Tooling — adding Features, authoring custom Features, or using Templates
- Advanced — multi-container, DinD/DooD, Kubernetes, cloud environments
- Optimisation — caching, pre-built images, named volumes, disk I/O
- Security — non-root users, UID mapping, secrets, hardened images
- Troubleshooting — permission errors, slow builds, SSH/GPG credential issues
Phase 2 — Load the Right Resource
Load the resource indicated in the Quick Reference Table. For complex tasks spanning multiple areas (e.g. "set up a secure multi-container environment with fast builds"), load both relevant files.
Phase 3 — Execute
Apply the guidance from the loaded resource. Use concrete examples from the resource files. For configuration tasks, produce a complete, commented devcontainer.json snippet.
Common Task Workflows
Workflow 1: Create a New Dev Container from Scratch
- Load
references/core-concepts.md for the full property reference
- Choose orchestration method:
image (simplest), build.dockerfile, or dockerComposeFile
- Add
features for tools (Node.js, Python, Git, Docker CLI, etc.)
- Set
remoteUser to a non-root user for security
- Add
customizations.vscode.extensions and settings for IDE consistency
- Add
postCreateCommand to install dependencies automatically
- Add
forwardPorts for any app ports
{
"name": "My Project",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/node:1": { "version": "20" },
"ghcr.io/devcontainers/features/git:1": {}
},
"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],
"settings": { "editor.formatOnSave": true }
}
},
"postCreateCommand": "npm install",
"forwardPorts": [3000],
"remoteUser": "node"
}
Workflow 2: Add a Tool via Features
- Load
references/features-templates.md
- Browse the official registry or GitHub Container Registry
- Add the feature with a pinned version to
devcontainer.json
- Use
overrideFeatureInstallOrder if ordering matters
Workflow 3: Multi-Container Setup with Docker Compose
- Load
references/advanced-config.md
- Create
docker-compose.yml for services (app, database, cache)
- Create
docker-compose.dev.yml for development overrides (source mounts, debug ports)
- Set
dockerComposeFile to both files in devcontainer.json
- Set
service to the container the IDE should attach to
- Set
shutdownAction: "none" to keep services running when IDE closes
Workflow 4: Speed Up Dev Container Builds
- Load
references/performance-security.md
- Order Dockerfile instructions from least-changed to most-changed
- Use
RUN --mount=type=cache for package managers
- Use named volumes for
node_modules / heavy dependency directories
- Pre-build and push image in CI; reference the pre-built image in
devcontainer.json
Workflow 5: Troubleshoot a Permission or Credential Issue
- Load
references/troubleshooting.md
- For UID mismatch: ensure
updateRemoteUserUID: true (default on Linux)
- For SSH: ensure local SSH agent is running; the extension auto-forwards it
- For Git inside container: use SSH agent forwarding; do not copy private keys
Resource Summaries
| File |
Contents |
Lines |
references/core-concepts.md |
Full devcontainer.json property reference, lifecycle hooks, location precedence |
~280 |
references/features-templates.md |
Consuming and authoring Features, Templates distribution, version pinning |
~260 |
references/advanced-config.md |
Multi-container, Docker-in-Docker/from-Docker, Kubernetes, Codespaces, DevPod |
~280 |
references/performance-security.md |
Layer caching, named volumes, pre-built images, non-root users, secrets |
~270 |
references/troubleshooting.md |
Permission errors, slow I/O, SSH/GPG credentials, lifecycle script issues |
~200 |
Best Practices
- Version-pin everything — pin Features (
feature:1) and base images (python:3.12) for reproducibility
- Non-root by default — always set
remoteUser to a non-root user; use updateRemoteUserUID: true on Linux
- Automate setup — use
postCreateCommand to install dependencies so the environment is immediately usable
- Don't modify production Compose — use a
docker-compose.dev.yml override for dev-specific additions
- Pre-build images in CI — reduces startup from minutes to seconds; embed metadata in image labels
- Never bake secrets into images — use SSH agent forwarding, BuildKit secret mounts, or
.env files (git-ignored)
- Named volumes for heavy directories — on macOS/Windows, mount
node_modules etc. into named volumes for native I/O speed
External References
1---2name: devcontainers3description: Provides expert guidance on Development Containers (devcontainers) — creating, configuring, and optimising containerised development environments using the Dev Container Specification. This skill should be used when users ask about devcontainer.json, .devcontainer setup, Dev Container Features or Templates, pre-building images, multi-container workflows, Docker-in-Docker, cloud development environments (Codespaces, DevPod), or troubleshooting container performance and permission issues.4---5
6# Dev Containers Skill
7
8Expert guidance on creating, configuring, and optimising containerised development environments using the [Dev Container Specification](https://containers.dev). Covers `devcontainer.json` authoring, Features, Templates, performance, security, multi-container setups, and cloud environments.
9
10## Quick Reference Table
11
12| Task | Load Resource | Key Concepts |
13|------|--------------|--------------|
14| Create or configure a `devcontainer.json` | `references/core-concepts.md` | image, build, features, lifecycle hooks, customizations |
15| Add tools/languages to a container | `references/features-templates.md` | Features, version pinning, installsAfter, Templates |
16| Set up multi-container or Docker-in-Docker | `references/advanced-config.md` | dockerComposeFile, DinD, DooD, Kubernetes, service |
17| Improve build/startup speed | `references/performance-security.md` | layer caching, named volumes, pre-built images, Virtio-fs |
18| Harden container security or manage secrets | `references/performance-security.md` | remoteUser, UID mapping, SSH forwarding, secrets |
19| Debug slow mounts, permission errors, credential issues | `references/troubleshooting.md` | UID/GID, bind mounts, SSH agent, postCreateCommand |
20| Integrate with Codespaces or DevPod | `references/advanced-config.md` | prebuilds, providers, SSH, cloud residency |
21
22## Orchestration Protocol
23
24### Phase 1 — Classify the Task
25
26Identify which category the user's request falls into:
27
28- **Configuration** — writing or editing `devcontainer.json`, Dockerfiles, Compose files
29- **Tooling** — adding Features, authoring custom Features, or using Templates
30- **Advanced** — multi-container, DinD/DooD, Kubernetes, cloud environments
31- **Optimisation** — caching, pre-built images, named volumes, disk I/O
32- **Security** — non-root users, UID mapping, secrets, hardened images
33- **Troubleshooting** — permission errors, slow builds, SSH/GPG credential issues
34
35### Phase 2 — Load the Right Resource
36
37Load the resource indicated in the Quick Reference Table. For complex tasks spanning multiple areas (e.g. "set up a secure multi-container environment with fast builds"), load **both** relevant files.
38
39### Phase 3 — Execute
40
41Apply the guidance from the loaded resource. Use concrete examples from the resource files. For configuration tasks, produce a complete, commented `devcontainer.json` snippet.
42
43## Common Task Workflows
44
45### Workflow 1: Create a New Dev Container from Scratch
46
471. Load `references/core-concepts.md` for the full property reference
482. Choose orchestration method: `image` (simplest), `build.dockerfile`, or `dockerComposeFile`
493. Add `features` for tools (Node.js, Python, Git, Docker CLI, etc.)
504. Set `remoteUser` to a non-root user for security
515. Add `customizations.vscode.extensions` and `settings` for IDE consistency
526. Add `postCreateCommand` to install dependencies automatically
537. Add `forwardPorts` for any app ports
54
55```json
56{
57 "name": "My Project",
58 "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
59 "features": {
60 "ghcr.io/devcontainers/features/node:1": { "version": "20" },
61 "ghcr.io/devcontainers/features/git:1": {}
62 },
63 "customizations": {
64 "vscode": {
65 "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"],
66 "settings": { "editor.formatOnSave": true }
67 }
68 },
69 "postCreateCommand": "npm install",
70 "forwardPorts": [3000],
71 "remoteUser": "node"
72}
73```
74
75### Workflow 2: Add a Tool via Features
76
771. Load `references/features-templates.md`
782. Browse the [official registry](https://containers.dev/features) or GitHub Container Registry
793. Add the feature with a pinned version to `devcontainer.json`
804. Use `overrideFeatureInstallOrder` if ordering matters
81
82### Workflow 3: Multi-Container Setup with Docker Compose
83
841. Load `references/advanced-config.md`
852. Create `docker-compose.yml` for services (app, database, cache)
863. Create `docker-compose.dev.yml` for development overrides (source mounts, debug ports)
874. Set `dockerComposeFile` to both files in `devcontainer.json`
885. Set `service` to the container the IDE should attach to
896. Set `shutdownAction: "none"` to keep services running when IDE closes
90
91### Workflow 4: Speed Up Dev Container Builds
92
931. Load `references/performance-security.md`
942. Order Dockerfile instructions from least-changed to most-changed
953. Use `RUN --mount=type=cache` for package managers
964. Use named volumes for `node_modules` / heavy dependency directories
975. Pre-build and push image in CI; reference the pre-built image in `devcontainer.json`
98
99### Workflow 5: Troubleshoot a Permission or Credential Issue
100
1011. Load `references/troubleshooting.md`
1022. For UID mismatch: ensure `updateRemoteUserUID: true` (default on Linux)
1033. For SSH: ensure local SSH agent is running; the extension auto-forwards it
1044. For Git inside container: use SSH agent forwarding; do not copy private keys
105
106## Resource Summaries
107
108| File | Contents | Lines |
109|------|----------|-------|
110| `references/core-concepts.md` | Full `devcontainer.json` property reference, lifecycle hooks, location precedence | ~280 |
111| `references/features-templates.md` | Consuming and authoring Features, Templates distribution, version pinning | ~260 |
112| `references/advanced-config.md` | Multi-container, Docker-in-Docker/from-Docker, Kubernetes, Codespaces, DevPod | ~280 |
113| `references/performance-security.md` | Layer caching, named volumes, pre-built images, non-root users, secrets | ~270 |
114| `references/troubleshooting.md` | Permission errors, slow I/O, SSH/GPG credentials, lifecycle script issues | ~200 |
115
116## Best Practices
117
118- **Version-pin everything** — pin Features (`feature:1`) and base images (`python:3.12`) for reproducibility
119- **Non-root by default** — always set `remoteUser` to a non-root user; use `updateRemoteUserUID: true` on Linux
120- **Automate setup** — use `postCreateCommand` to install dependencies so the environment is immediately usable
121- **Don't modify production Compose** — use a `docker-compose.dev.yml` override for dev-specific additions
122- **Pre-build images in CI** — reduces startup from minutes to seconds; embed metadata in image labels
123- **Never bake secrets into images** — use SSH agent forwarding, BuildKit secret mounts, or `.env` files (git-ignored)
124- **Named volumes for heavy directories** — on macOS/Windows, mount `node_modules` etc. into named volumes for native I/O speed
125
126## External References
127
128- [Dev Container Specification](https://containers.dev) — official specification and schema
129- [devcontainer.json reference](https://containers.dev/implementors/json_reference/) — full property reference
130- [Official Features registry](https://containers.dev/features) — browse available Features
131- [Official Templates registry](https://containers.dev/templates) — browse available Templates
132- [VS Code Dev Containers docs](https://code.visualstudio.com/docs/devcontainers/containers) — IDE integration guide
133- [GitHub Codespaces docs](https://docs.github.com/en/codespaces) — cloud-hosted containers
134- [DevPod docs](https://devpod.sh/docs) — open-source provider-agnostic cloud dev environments
135- [devcontainers/cli](https://github.com/devcontainers/cli) — reference CLI implementation