Dev Containers in 2026: VS Code devcontainers, GitHub Codespaces, and Reproducible Dev Environments
Build reproducible developer environments with Dev Containers: VS Code devcontainer.json configuration, GitHub Codespaces setup, Docker Compose integration, and custom features.
Dev Containers in 2026: VS Code devcontainers, GitHub Codespaces, and Reproducible Dev Environments
"Works on my machine" is a solved problem. Dev Containers define the entire development environment as code โ the OS, language runtime, tools, extensions, and services โ so every developer on the team has an identical setup from day one, whether they're on macOS, Windows, Linux, or a browser via GitHub Codespaces.
The time investment is a few hours to configure a Dev Container properly; the payoff is every new engineer being productive on day one instead of spending two days fighting environment setup.
Dev Container vs Docker Compose vs setup.sh
| Approach | Reproducibility | IDE Integration | New Engineer Setup |
|---|---|---|---|
setup.sh | Medium (can drift) | โ | 1โ4 hours |
| Docker Compose only | High | โ (external containers) | 30 min + config |
| Dev Container | Very high | โ Full VS Code/JetBrains | < 5 min |
| GitHub Codespaces | Very high | โ Browser or local | < 2 min |
Dev Containers are Docker containers that your IDE opens as the development environment โ you write and debug code inside the container, so the environment is identical for everyone.
Basic devcontainer.json
// .devcontainer/devcontainer.json
{
"name": "MyApp Development",
// Use a pre-built base image or your own Dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:22-bookworm",
// Features: add tools to the base image without a custom Dockerfile
"features": {
// PostgreSQL client tools
"ghcr.io/devcontainers/features/postgres-client:1": {
"version": "17"
},
// AWS CLI
"ghcr.io/devcontainers/features/aws-cli:1": {},
// GitHub CLI
"ghcr.io/devcontainers/features/github-cli:1": {},
// Docker-in-Docker (to run Docker commands inside the container)
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
// VS Code extensions installed automatically
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"prisma.prisma",
"bradlc.vscode-tailwindcss",
"ms-azuretools.vscode-docker",
"eamodio.gitlens",
"github.copilot",
"usernamehw.errorlens",
"ms-vscode.vscode-typescript-next"
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.validate": ["typescript", "typescriptreact"],
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
}
},
// Port forwarding: expose container ports to host
"forwardPorts": [3000, 3001, 5432, 6379],
"portsAttributes": {
"3000": { "label": "Web App", "onAutoForward": "openBrowser" },
"3001": { "label": "API Server" },
"5432": { "label": "PostgreSQL" },
"6379": { "label": "Redis" }
},
// Run after container creation (install deps, set up DB)
"postCreateCommand": "bash .devcontainer/post-create.sh",
// Run after VS Code opens (start dev server)
"postStartCommand": "docker compose up -d postgres redis mailpit",
// Mount SSH keys and git config from host
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,consistency=cached"
],
// Run as non-root user
"remoteUser": "node",
// Environment variables available inside container
"remoteEnv": {
"NODE_ENV": "development",
"AWS_PROFILE": "myapp-dev"
}
}
๐ Looking for a Dev Team That Actually Delivers?
Most agencies sell you a project manager and assign juniors. Viprasol is different โ senior engineers only, direct Slack access, and a 5.0โ Upwork record across 100+ projects.
- React, Next.js, Node.js, TypeScript โ production-grade stack
- Fixed-price contracts โ no surprise invoices
- Full source code ownership from day one
- 90-day post-launch support included
Post-Create Script
#!/usr/bin/env bash
# .devcontainer/post-create.sh
# Runs once after container is first created
set -euo pipefail
echo "๐ง Setting up development environment..."
# Install npm dependencies
npm ci
# Set up environment file if not present
if [ ! -f .env.local ]; then
cp .env.example .env.local
echo "โ ๏ธ .env.local created from example. Add secrets before starting."
fi
# Wait for PostgreSQL to be ready
echo "โณ Waiting for PostgreSQL..."
timeout 60 bash -c '
while ! pg_isready -h localhost -U myapp -d myapp 2>/dev/null; do
sleep 1
done
'
# Run database migrations
echo "๐๏ธ Running database migrations..."
npx prisma migrate dev --skip-generate
# Seed database
echo "๐ฑ Seeding database..."
npx ts-node prisma/seed.ts
# Install pre-commit hooks
echo "๐ช Installing git hooks..."
npx husky
echo "โ
Setup complete! Start developing:"
echo " npm run dev โ http://localhost:3000"
Docker Compose Integration
For projects with multiple services, use Docker Compose within the Dev Container:
// .devcontainer/devcontainer.json โ Docker Compose variant
{
"name": "MyApp Development",
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.dev.yml" // Dev-specific overrides
],
"service": "app", // Which service is the dev container
"workspaceFolder": "/workspace",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
},
"postCreateCommand": "npm ci && npx prisma migrate dev",
"forwardPorts": [3000, 5432]
}
# .devcontainer/docker-compose.dev.yml โ Overrides for dev environment
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
# Mount source code (not copied โ edits reflected immediately)
- ..:/workspace:cached
# Preserve node_modules inside container (faster than host filesystem)
- node_modules:/workspace/node_modules
command: sleep infinity # Keep container running; VS Code attaches
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://myapp:myapp@postgres:5432/myapp
- REDIS_URL=redis://redis:6379
volumes:
node_modules:
๐ Senior Engineers. No Junior Handoffs. Ever.
You get the senior developer, not a project manager who relays your requirements to someone you never meet. Every Viprasol project has a senior lead from kickoff to launch.
- MVPs in 4โ8 weeks, full platforms in 3โ5 months
- Lighthouse 90+ performance scores standard
- Works across US, UK, AU timezones
- Free 30-min architecture review, no commitment
Custom Dockerfile for Complex Environments
# .devcontainer/Dockerfile
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
# Install Node.js 22 via nvm (matches .nvmrc)
ARG NODE_VERSION=22
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh \
&& nvm install ${NODE_VERSION} \
&& nvm alias default ${NODE_VERSION}" 2>&1
# Install PostgreSQL 17 client
RUN apt-get update && apt-get install -y \
postgresql-client-17 \
&& rm -rf /var/lib/apt/lists/*
# Install global npm tools
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh \
&& npm install -g \
typescript \
ts-node \
prisma \
@railway/cli"
# Install AWS CLI v2
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip" \
&& unzip /tmp/awscliv2.zip -d /tmp \
&& /tmp/aws/install \
&& rm -rf /tmp/aws /tmp/awscliv2.zip
# Set default shell to zsh with oh-my-zsh (already in base image)
USER vscode
GitHub Codespaces Configuration
Codespaces uses the same devcontainer.json โ your Dev Container is automatically a Codespace. Add Codespaces-specific optimizations:
// .devcontainer/devcontainer.json โ Codespaces additions
{
// ... existing config ...
// Machine type recommendation
"hostRequirements": {
"cpus": 4,
"memory": "8gb",
"storage": "32gb"
},
// Prebuild: GitHub Action caches the container build
// Set up in repo Settings โ Codespaces โ Prebuild configuration
// Reduces startup time from 3-5 min to < 30 seconds
// Codespaces secrets (set in GitHub repo settings)
"secrets": {
"DATABASE_URL": {
"description": "PostgreSQL connection string for development",
"documentationUrl": "https://github.com/myorg/myapp/wiki/Dev-Secrets"
}
}
}
Prebuilds GitHub Action
# .github/workflows/codespaces-prebuild.yml
name: Codespaces Prebuild
on:
push:
branches: [main]
paths:
- '.devcontainer/**'
- 'package-lock.json'
- 'prisma/schema.prisma'
jobs:
prebuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Trigger Codespaces prebuild
uses: github/codespaces-prebuilds-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
Dev Container Features: Common Additions
// Common features to add to devcontainer.json
{
"features": {
// Terraform for IaC work
"ghcr.io/devcontainers/features/terraform:1": {
"version": "latest",
"tflint": "latest"
},
// Python (for scripts and ML work alongside Node)
"ghcr.io/devcontainers/features/python:1": {
"version": "3.12"
},
// kubectl + helm for Kubernetes work
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"version": "latest",
"helm": "latest"
},
// Git LFS for large files
"ghcr.io/devcontainers/features/git-lfs:1": {},
// sops for encrypted secrets
"ghcr.io/devcontainers-contrib/features/sops:1": {}
}
}
Onboarding Time Comparison
| Onboarding Method | First PR Time | Setup Issues | Machine-Dependent Bugs |
|---|---|---|---|
| README + manual setup | 1โ3 days | Common | Frequent |
| setup.sh script | 2โ4 hours | Occasional | Some |
| Dev Container | 10โ30 minutes | Rare | Never |
| GitHub Codespaces | < 5 minutes | None | Never |
Working With Viprasol
We set up Dev Container environments for engineering teams โ cutting new engineer onboarding from days to minutes.
What we deliver:
devcontainer.jsonconfiguration for your stack (Node/Python/Go/etc.)- Docker Compose integration with all development services
- GitHub Codespaces prebuild setup for instant cloud development
- VS Code extension list and settings standardized for your team
- Post-create automation (migrations, seeding, hook installation)
โ Discuss your developer environment setup โ DevOps and platform engineering
See Also
About the Author
Viprasol Tech Team
Custom Software Development Specialists
The Viprasol Tech team specialises in algorithmic trading software, AI agent systems, and SaaS development. With 100+ projects delivered across MT4/MT5 EAs, fintech platforms, and production AI systems, the team brings deep technical experience to every engagement. Based in India, serving clients globally.
Need a Modern Web Application?
From landing pages to complex SaaS platforms โ we build it all with Next.js and React.
Free consultation โข No commitment โข Response within 24 hours
Need a custom web application built?
We build React and Next.js web applications with Lighthouse โฅ90 scores, mobile-first design, and full source code ownership. Senior engineers only โ from architecture through deployment.