Dev Containers
Primary Actions
- Create or update
.devcontainer/devcontainer.json. - Configure features, editor extensions, and lifecycle hooks.
- Set up multi-container dev environments via Docker Compose.
- Configure Codespaces-specific requirements when needed.
- Diagnose and fix container startup/build/runtime issues.
Minimal Template
{
"name": "My Project",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/python:1": { "version": "3.12" }
},
"customizations": {
"vscode": {
"extensions": ["ms-python.python"]
}
},
"postCreateCommand": "pip install -e '.[dev]'"
}
Validation Workflow
- Create/update
devcontainer.json. - Validate build:
devcontainer build --workspace-folder .
- Rebuild/reopen container in editor.
- Verify lifecycle hooks and required extensions.
- If using Compose, verify dependent services are healthy/reachable.
- If failures occur, fix config and repeat from step 2.
Deep References
- Full
devcontainer.jsonschema and lifecycle hooks:
references/devcontainer-json.md
- Features, customization, prebuilds, machine options:
references/features-and-customization.md
- Validation and troubleshooting workflow:
references/validation-and-troubleshooting.md