Standard DevContainers can become bloated and difficult to manage, often requiring complex, manual setup for cross-platform development environments.
This project provides a clean, minimal boilerplate for devcontainer.json and Dockerfile to standardize development environments across Windows (WSL) and macOS. See devcontainer.json.
I prioritized a hybrid security model that splits ownership: leveraging the trust of official cloud registries (Microsoft/GitHub) for the supply chain, while enforcing local sandboxing (non-root execution) for container behavior.
- Cross-platform compatibility (WSL/macOS)
- Minimal boilerplate architecture
- Rootless execution (non-privileged user
vscode) - Verified supply chain integration
Before using these DevContainers, ensure your environment meets these requirements:
- WSL 2: Must be installed and running a supported Linux distribution (e.g., Ubuntu).
- Docker Desktop: Ensure WSL 2 integration is enabled in the Docker Desktop settings.
- VS Code: Installed on Windows, with the Dev Containers extension installed.
- Docker Desktop: Ensure Docker is running.
- VS Code: Installed on macOS, with the Dev Containers extension installed.
Quick Verification: Before initializing, run
docker --version. If it fails, the DevContainer engine cannot build your image.
mkdir -p ~/projects/code/.devcontainer
cd ~/projects/codeCopy the example devcontainer.json and Dockerfile into the .devcontainer folder.
Tip: The Dockerfile is only needed for customization beyond the devcontainer.json (e.g., additional system dependencies or custom config file injection).
- Open VS Code.
- Mount the workspace directory:
- Windows/WSL: Open your remote terminal, File > Open Folder... and select your project root.
- macOS: File > Open Folder... and select your project root.
- Press
Ctrl + Shift + P/Cmd + Shift + Pto open the Command Palette. - Select Dev Containers: Reopen in Container.
- Rebuilds: Editing
devcontainer.jsontriggers a rebuild. If you need to force a rebuild, use the Dev Containers: Rebuild Container command from the Command PaletteCtrl + Shift + P/Cmd + Shift + P. - Updates: Base images are available via the Microsoft Artifact Registry. You can pin specific build tags for version consistency.
This hybrid model enforces security by splitting ownership:
- Verified Base Images: Pulling from
mcr.microsoft.comensures officially maintained, scanned, and signed base layers. - Managed Features: Using the
"features"block fromghcr.ioavoids arbitrary install scripts, mitigating supply chain risks.
- No Root Access:
"remoteUser": "vscode"restricts the container to a non-privileged user, dramatically reducing the blast radius if an process is compromised. - Tool Isolation: Host machine configuration remains clean; the container sandboxes all tools (Azure CLI, Terraform, Python) within the project scope.
MIT