Skip to content

Dev Containers Setup Guide

Complete guide for the VS Code Dev Container environment

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
PlatformRecommendedAlternatives
Windows 10/11 ProDocker Desktop with WSL 2Rancher Desktop, Podman
Windows 10/11 HomeDocker Desktop with WSL 2 (2004+)
macOSDocker Desktop 2.0+Colima, Rancher Desktop
LinuxDocker CE/EE 18.06+Podman
ResourceMinimumRecommended
RAM8 GB16 GB
CPU2 cores4+ cores
Disk10 GB free20 GB free
SoftwareVersionPurpose
VS CodeLatestIDE
Dev Containers ExtensionLatestContainer integration
DockerSee aboveContainer runtime
Git2.30+Version control

=== “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 Applications
3. Wait for "Docker Desktop is running"

=== “Linux”

```bash
# Ubuntu/Debian
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
# Log out and back in for group changes
# Verify
docker --version
```
Terminal window
code --install-extension ms-vscode-remote.remote-containers

Or install from Extensions (Ctrl+Shift+X) → search “Dev Containers”.

Terminal window
git clone https://github.com/YOUR-USERNAME/my-infraops-project.git
cd my-infraops-project
code .

Press F1Dev Containers: Reopen in Container

First build takes 2-5 minutes. Subsequent opens are instant.

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.

  1. Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens

  2. Click Generate new token

  3. Set expiry (90 days recommended; rotate via calendar reminder)

  4. Repository access: All repositories, or select specific ones

  5. Permissions — minimum required:

    PermissionLevel
    ContentsRead/Write
    MetadataRead
    Pull requestsRead/Write
    IssuesRead/Write
    WorkflowsRead/Write
  6. 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)”
  1. Open VS Code Settings: Ctrl+, (or Cmd+, on macOS)
  2. Click the Open Settings (JSON) icon (top-right)
  3. Add this entry (replace the placeholder with your actual token):
"terminal.integrated.env.linux": { "GH_TOKEN": "github_pat_your_token_here" }
  1. Save the file
  2. 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).

Terminal window
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).

Terminal window
az --version && bicep --version && pwsh --version

Rancher Desktop (Free Docker Desktop Alternative)

Section titled “Rancher Desktop (Free Docker Desktop Alternative)”
  1. Download from rancherdesktop.io
  2. Choose “dockerd (moby)” as runtime
  3. Works with VS Code Dev Containers extension
Terminal window
brew install colima docker
colima start
Terminal window
# macOS
brew install podman
podman machine init
podman machine start
# Linux
sudo apt install podman

Configure VS Code: "dev.containers.dockerPath": "podman"

The Dev Container includes:

CategoryTools
AzureAzure CLI 2.50+, Bicep CLI 0.30+, Azure Pricing MCP
TerraformTerraform (latest), tfsec, HashiCorp Terraform MCP Server
PowerShellPowerShell 7+, Az modules
PythonPython 3.13+, diagrams library, graphviz
Node.jsNode LTS+, npm, markdownlint
VS Code Extensions27+ extensions (Bicep, Terraform, Copilot, Azure, etc.)

Auto-updates on start: terraform-mcp-server, Azure Pricing MCP, npm deps, markdownlint-cli2, checkov, ruff, and diagrams are refreshed automatically on every container start via post-start.sh. Heavy tools (PowerShell modules, system packages) are installed once at build time.

Terminal window
# Check Docker is running
docker ps
# Rebuild without cache
# F1 → Dev Containers: Rebuild Container Without Cache

Stop other containers using the same ports:

Terminal window
docker ps
docker stop <container-id>
  • Increase Docker Desktop memory allocation (Settings → Resources)
  • Use WSL 2 backend on Windows (faster than Hyper-V)
  • Close unnecessary applications
Terminal window
# Force extension reinstall
# F1 → Developer: Reload Window