Back to Blog

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.

Viprasol Tech Team
August 27, 2026
12 min read

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

ApproachReproducibilityIDE IntegrationNew Engineer Setup
setup.shMedium (can drift)โŒ1โ€“4 hours
Docker Compose onlyHighโŒ (external containers)30 min + config
Dev ContainerVery highโœ… Full VS Code/JetBrains< 5 min
GitHub CodespacesVery 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 MethodFirst PR TimeSetup IssuesMachine-Dependent Bugs
README + manual setup1โ€“3 daysCommonFrequent
setup.sh script2โ€“4 hoursOccasionalSome
Dev Container10โ€“30 minutesRareNever
GitHub Codespaces< 5 minutesNoneNever

Working With Viprasol

We set up Dev Container environments for engineering teams โ€” cutting new engineer onboarding from days to minutes.

What we deliver:

  • devcontainer.json configuration 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

Share this article:

About the Author

V

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.

MT4/MT5 EA DevelopmentAI Agent SystemsSaaS DevelopmentAlgorithmic Trading

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

Viprasol ยท Web Development

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.