# Coder Development Workspaces

> Coder for remote development environments.

- Category: Development Tools
- Difficulty: advanced
- Components: coder, postgresql, envbuilder
- Tags: coder, remote-dev, workspaces, cloud-ide
- Source: https://docker.recipes/development/coder-workspace-stack

## Overview

Coder is an open-source platform that enables organizations to provision secure, standardized development environments in the cloud or on-premises infrastructure. Originally developed to address the challenges of remote development, Coder creates consistent, reproducible workspaces that can be accessed from anywhere via a web browser or SSH. This platform eliminates the 'works on my machine' problem by ensuring all developers work within identical environments while maintaining the flexibility to customize tooling and configurations.

This stack combines Coder with PostgreSQL to create a robust remote development platform. PostgreSQL serves as Coder's metadata store, tracking workspace definitions, user sessions, provisioning state, and audit logs with ACID compliance ensuring data integrity during concurrent operations. The database handles complex queries for workspace analytics, user permissions, and resource allocation while supporting Coder's template system that defines how development environments are provisioned and configured.

Development teams transitioning to remote work, organizations seeking to standardize development environments, and companies managing large engineering teams will benefit from this configuration. The combination provides enterprise-grade reliability through PostgreSQL's proven stability while Coder delivers instant workspace provisioning, consistent development environments across team members, and centralized management of development resources. This setup particularly excels in environments where security, compliance, and resource optimization are critical requirements.

## Features

- Template-based workspace provisioning with infrastructure-as-code definitions
- Web-based VS Code, JetBrains Gateway, and SSH access to development environments
- PostgreSQL-backed audit logging and workspace state management with ACID compliance
- Docker socket integration for container-based development environment provisioning
- Multi-user workspace management with role-based access control and quotas
- Real-time workspace status monitoring and resource usage analytics
- Git-ops workflow integration with automated environment updates
- Workspace hibernation and automatic resource cleanup to optimize costs

## Use cases

- Remote engineering teams needing consistent development environments across distributed developers
- Organizations onboarding new developers who require immediate access to fully configured workspaces
- Companies implementing security policies that restrict local development on employee devices
- Educational institutions providing students with standardized programming environments
- Enterprises managing compliance requirements through centralized development environment control
- Startups optimizing cloud costs by sharing development infrastructure and automatic resource cleanup
- Open source projects offering contributors pre-configured development environments

## Prerequisites

- Docker Engine with daemon socket access for workspace container provisioning
- Minimum 4GB RAM (8GB+ recommended for multiple concurrent workspaces)
- Port 7080 available for Coder web interface access
- Understanding of infrastructure-as-code concepts for workspace template creation
- Basic PostgreSQL administration knowledge for database maintenance and backups
- Familiarity with container networking and volume management concepts

## docker-compose.yml

```yaml
services:
  coder:
    image: ghcr.io/coder/coder:latest
    container_name: coder
    restart: unless-stopped
    ports:
      - "${CODER_PORT:-7080}:7080"
    environment:
      - CODER_PG_CONNECTION_URL=postgres://${DB_USER}:${DB_PASSWORD}@coder-db/coder?sslmode=disable
      - CODER_HTTP_ADDRESS=0.0.0.0:7080
      - CODER_ACCESS_URL=http://localhost:${CODER_PORT:-7080}
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - coder_data:/home/coder/.config
    depends_on:
      - coder-db

  coder-db:
    image: postgres:15-alpine
    container_name: coder-db
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=coder
    volumes:
      - coder_db_data:/var/lib/postgresql/data

volumes:
  coder_data:
  coder_db_data:
```

## .env

```bash
# Coder
CODER_PORT=7080
DB_USER=coder
DB_PASSWORD=coder_password
```

## Usage notes

- Coder at http://localhost:7080
- Create first user on startup
- Define workspace templates
- Docker or Kubernetes backends

## Troubleshooting

- Coder fails to start with 'connection refused' database error: Ensure PostgreSQL container is fully initialized before Coder starts, add health checks or startup delays
- Workspace provisioning fails with Docker socket permission denied: Verify /var/run/docker.sock has correct permissions and Coder container runs with appropriate user privileges
- PostgreSQL connection pool exhausted during high workspace activity: Increase max_connections in PostgreSQL configuration and tune Coder's database connection pool settings
- Workspace templates fail to execute with 'template not found' errors: Check template definitions are properly committed to database and Coder has read permissions
- Coder web interface inaccessible from external networks: Verify CODER_ACCESS_URL matches your actual domain/IP and firewall rules allow traffic on configured port

