# VS Code Dev Container Fullstack

> Complete development environment with VS Code Server and fullstack tools.

- Category: Development Tools
- Difficulty: intermediate
- Components: code-server, node, python, postgresql, redis
- Tags: devcontainer, vscode, fullstack, remote, development
- Source: https://docker.recipes/development/devcontainer-fullstack

## Overview

code-server brings VS Code's full IDE experience to any device through a web browser, eliminating the need for local installations while maintaining access to extensions, integrated terminals, and debugging capabilities. Originally created by Coder to enable remote development, it has become the foundation for cloud-based development environments that offer consistent tooling across teams and devices. This fullstack development container combines code-server with Node.js 20 and Python 3.11 runtimes alongside PostgreSQL for robust relational data storage and Redis for high-performance caching and session management. The stack includes MailHog for email testing during development and Adminer for database administration, creating a complete development ecosystem within isolated containers. Remote development teams, consultants working across multiple client environments, and organizations standardizing development toolchains will find this combination particularly valuable for maintaining consistency while enabling flexible access from any device with a modern web browser.

## Features

- Full VS Code interface accessible through web browser with extension marketplace support
- Node.js 20 Alpine runtime with persistent node_modules volume for JavaScript/TypeScript development
- Python 3.11 slim container with virtual environment persistence for backend API development
- PostgreSQL 15 with ACID compliance, JSON/JSONB support, and full-text search capabilities
- Redis 7 in-memory data structures for sub-millisecond caching, session storage, and pub/sub messaging
- MailHog SMTP testing server with web interface for capturing and inspecting development emails
- Adminer web-based database administration with support for PostgreSQL schema management
- Persistent workspace synchronization across container restarts and updates

## Use cases

- Remote fullstack development teams building web applications with JavaScript frontend and Python backend
- Consulting developers who need consistent environments across different client projects and machines
- Educational institutions providing standardized development environments for coding bootcamps and computer science courses
- Companies developing applications with PostgreSQL databases requiring email functionality testing
- Freelancers working on Chromebooks or tablets who need access to a full development environment
- Startups building MVP applications with real-time features using Redis pub/sub and PostgreSQL persistence
- Development teams creating API services that require session management, caching, and transactional data storage

## Prerequisites

- Docker Engine 20.10+ and Docker Compose V2 with minimum 4GB RAM allocated to containers
- Available ports 8443, 8080, 8025, 1025, 5432, and 6379 on the host system
- CODE_PASSWORD and POSTGRES_PASSWORD environment variables configured in .env file
- Basic understanding of VS Code extensions and terminal usage for development workflows
- Familiarity with PostgreSQL connection strings and Redis CLI commands for database interactions
- Modern web browser with JavaScript enabled for accessing code-server interface

## docker-compose.yml

```yaml
services:
  code-server:
    image: codercom/code-server:latest
    ports:
      - "8443:8443"
    environment:
      - PASSWORD=${CODE_PASSWORD}
    volumes:
      - ./workspace:/home/coder/project
      - code_server_data:/home/coder/.local
    user: root
    networks:
      - dev_net

  node:
    image: node:20-alpine
    working_dir: /app
    volumes:
      - ./workspace:/app
      - node_modules:/app/node_modules
    command: tail -f /dev/null
    networks:
      - dev_net

  python:
    image: python:3.11-slim
    working_dir: /app
    volumes:
      - ./workspace:/app
      - python_venv:/app/.venv
    command: tail -f /dev/null
    networks:
      - dev_net

  postgres:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=dev
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=devdb
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    networks:
      - dev_net

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - dev_net

  mailhog:
    image: mailhog/mailhog:latest
    ports:
      - "1025:1025"
      - "8025:8025"
    networks:
      - dev_net

  adminer:
    image: adminer:latest
    ports:
      - "8080:8080"
    networks:
      - dev_net

volumes:
  code_server_data:
  node_modules:
  python_venv:
  postgres_data:
  redis_data:

networks:
  dev_net:
```

## .env

```bash
# Dev Container
CODE_PASSWORD=secure_code_password
POSTGRES_PASSWORD=secure_postgres_password

# Code Server at http://localhost:8443
# Mailhog at http://localhost:8025
# Adminer at http://localhost:8080
```

## Usage notes

- Code Server at http://localhost:8443
- Mailhog for email testing at http://localhost:8025
- Adminer at http://localhost:8080
- Node and Python containers ready
- Install extensions in Code Server

## Troubleshooting

- code-server shows 'VS Code Server failed to start': Ensure CODE_PASSWORD environment variable is set and container has sufficient memory allocation
- Node.js modules not persisting between restarts: Verify node_modules volume is properly mounted and the container has write permissions to /app directory
- PostgreSQL connection refused from other containers: Check that services are on the same dev_net network and use service name 'postgres' instead of localhost
- Redis commands timeout or fail: Confirm Redis container is running and accessible on port 6379 within the Docker network, not from external connections
- MailHog not capturing emails from applications: Configure SMTP settings to use mailhog:1025 as the server address within the container network
- Adminer cannot connect to PostgreSQL: Use server name 'postgres', username 'dev', and ensure POSTGRES_PASSWORD matches the environment variable

