Dev Containers Setup Guide
Complete guide for the VS Code Dev Container environment
What Are Dev Containers?
Section titled “What Are Dev Containers?”Dev Containers use Docker to create a full-featured development environment inside a container. When you open this repository in a Dev Container:
- All required tools are pre-installed (Azure CLI, Bicep, PowerShell 7)
- VS Code extensions are automatically configured
- Git credentials are shared from your host machine
- The environment matches what other team members use
System Requirements
Section titled “System Requirements”Docker Options
Section titled “Docker Options”| Platform | Recommended | Alternatives |
|---|---|---|
| Windows 10/11 Pro | Docker Desktop with WSL 2 | Rancher Desktop, Podman |
| Windows 10/11 Home | Docker Desktop with WSL 2 (2004+) | — |
| macOS | Docker Desktop 2.0+ | Colima, Rancher Desktop |
| Linux | Docker CE/EE 18.06+ | Podman |
Hardware
Section titled “Hardware”| Resource | Minimum | Recommended |
|---|---|---|
| RAM | 8 GB | 16 GB |
| CPU | 2 cores | 4+ cores |
| Disk | 10 GB free | 20 GB free |
Software
Section titled “Software”| Software | Version | Purpose |
|---|---|---|
| VS Code | Latest | IDE |
| Dev Containers Extension | Latest | Container integration |
| Docker | See above | Container runtime |
| Git | 2.30+ | Version control |
Installation Steps
Section titled “Installation Steps”Step 1: Install Docker
Section titled “Step 1: Install Docker”=== “Windows (WSL 2)”
```powershell# Install WSL 2 (if not already installed)wsl --install
# Then download and install Docker Desktop# https://www.docker.com/products/docker-desktop
# Enable WSL 2 backend in Docker Desktop settings```=== “macOS”
1. Download [Docker Desktop for Mac](https://www.docker.com/products/docker-desktop)2. Start Docker Desktop from Applications3. Wait for "Docker Desktop is running"=== “Linux”
```bash# Ubuntu/Debiancurl -fsSL https://get.docker.com | shsudo usermod -aG docker $USER# Log out and back in for group changes
# Verifydocker --version```Step 2: Install VS Code Extension
Section titled “Step 2: Install VS Code Extension”code --install-extension ms-vscode-remote.remote-containersOr install from Extensions (Ctrl+Shift+X) → search “Dev Containers”.
Step 3: Open in Dev Container
Section titled “Step 3: Open in Dev Container”git clone https://github.com/YOUR-USERNAME/my-infraops-project.gitcd my-infraops-projectcode .Press F1 → Dev Containers: Reopen in Container
First build takes 2-5 minutes. Subsequent opens are instant.
Step 4: GitHub CLI Authentication (PAT)
Section titled “Step 4: GitHub CLI Authentication (PAT)”HTTPS-based gh auth login can fail inside dev containers on some platforms (Windows, ARM, WSL 2).
The only supported approach is a Personal Access Token (PAT) set in VS Code User Settings.
The container reads it automatically — no gh auth login required inside the container.
Create a Fine-Grained PAT
Section titled “Create a Fine-Grained PAT”-
Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens
-
Click Generate new token
-
Set expiry (90 days recommended; rotate via calendar reminder)
-
Repository access: All repositories, or select specific ones
-
Permissions — minimum required:
Permission Level Contents Read/Write Metadata Read Pull requests Read/Write Issues Read/Write Workflows Read/Write -
Copy the token (
github_pat_...)
Add to VS Code User Settings (once per machine)
Section titled “Add to VS Code User Settings (once per machine)”- Open VS Code Settings: Ctrl+, (or Cmd+, on macOS)
- Click the Open Settings (JSON) icon (top-right)
- Add this entry (replace the placeholder with your actual token):
"terminal.integrated.env.linux": { "GH_TOKEN": "github_pat_your_token_here" }- Save the file
- Rebuild the devcontainer: F1 → Dev Containers: Rebuild Container
The devcontainer forwards GH_TOKEN from VS Code’s environment automatically
("GH_TOKEN": "${localEnv:GH_TOKEN}" in devcontainer.json).
Verify inside the container
Section titled “Verify inside the container”gh auth status# Expected: ✓ Logged in to github.com as <your-username> (token)Token rotation: When your PAT expires, update the value in VS Code User Settings and rebuild the container (
F1 → Dev Containers: Rebuild Container).
Step 5: Verify Setup
Section titled “Step 5: Verify Setup”az --version && bicep --version && pwsh --versionAlternative Docker Options
Section titled “Alternative Docker Options”Rancher Desktop (Free Docker Desktop Alternative)
Section titled “Rancher Desktop (Free Docker Desktop Alternative)”- Download from rancherdesktop.io
- Choose “dockerd (moby)” as runtime
- Works with VS Code Dev Containers extension
Colima (macOS Only)
Section titled “Colima (macOS Only)”brew install colima dockercolima startPodman (Linux/macOS)
Section titled “Podman (Linux/macOS)”# macOSbrew install podmanpodman machine initpodman machine start
# Linuxsudo apt install podmanConfigure VS Code: "dev.containers.dockerPath": "podman"
What’s Included
Section titled “What’s Included”The Dev Container includes:
| Category | Tools |
|---|---|
| Azure | Azure CLI 2.50+, Bicep CLI 0.30+, Azure Pricing MCP |
| Terraform | Terraform (latest), tfsec, HashiCorp Terraform MCP Server |
| PowerShell | PowerShell 7+, Az modules |
| Python | Python 3.13+, diagrams library, graphviz |
| Node.js | Node LTS+, npm, markdownlint |
| VS Code Extensions | 27+ extensions (Bicep, Terraform, Copilot, Azure, etc.) |
Auto-updates on start:
terraform-mcp-server, Azure Pricing MCP, npm deps,markdownlint-cli2,checkov,ruff, anddiagramsare refreshed automatically on every container start viapost-start.sh. Heavy tools (PowerShell modules, system packages) are installed once at build time.
Troubleshooting
Section titled “Troubleshooting”Container Won’t Start
Section titled “Container Won’t Start”# Check Docker is runningdocker ps
# Rebuild without cache# F1 → Dev Containers: Rebuild Container Without CachePort Conflicts
Section titled “Port Conflicts”Stop other containers using the same ports:
docker psdocker stop <container-id>Slow Performance (Windows/macOS)
Section titled “Slow Performance (Windows/macOS)”- Increase Docker Desktop memory allocation (Settings → Resources)
- Use WSL 2 backend on Windows (faster than Hyper-V)
- Close unnecessary applications
Extensions Not Loading
Section titled “Extensions Not Loading”# Force extension reinstall# F1 → Developer: Reload Window