DEV Community

Russell Jones
Russell Jones

Posted on • Originally published at jonesrussell.github.io on

Setting Up a Dev Container in VS Code

Ahnii,

Tired of “it works on my machine” syndrome? Let’s fix that with VS Code Dev Containers! I recently switched to using them for all my projects, and it’s been a game-changer.

What are Dev Containers? (2 minutes)

Dev Containers provide:

  • Isolated development environments
  • Consistent tooling across team members
  • Project-specific configurations
  • Easy onboarding for new developers

Quick Setup (5 minutes)

  1. Prerequisites
    • Install Docker Desktop
    • Install VS Code
    • Add “Dev Containers” extension
  2. Basic Configuration
{
    "name": "Your Project",
    "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
    "customizations": {
        "vscode": {
            "extensions": [
                "dbaeumer.vscode-eslint",
                "esbenp.prettier-vscode"
            ]
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Pro Tips

  • Use multi-stage builds for smaller images
  • Share your Docker cache between containers
  • Mount your SSH keys safely
  • Configure Git settings properly

Common Issues and Solutions

  1. Performance
    • Use volume mounts wisely
    • Enable BuildKit
    • Optimize your Dockerfile
  2. Security
    • Never expose sensitive data in images
    • Use COPY instead of ADD
    • Keep base images updated

Wrapping Up

Dev Containers have transformed how I work with different projects. They’re worth the initial setup time for the consistency and reliability they provide.

What’s your development environment setup like? Have you tried Dev Containers? Share your experiences below!

Baamaapii 👋

Top comments (0)