docker.recipes

Coder Development Workspaces

advanced

Coder for remote development environments.

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.

Key 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

Common Use Cases

  • 1Remote engineering teams needing consistent development environments across distributed developers
  • 2Organizations onboarding new developers who require immediate access to fully configured workspaces
  • 3Companies implementing security policies that restrict local development on employee devices
  • 4Educational institutions providing students with standardized programming environments
  • 5Enterprises managing compliance requirements through centralized development environment control
  • 6Startups optimizing cloud costs by sharing development infrastructure and automatic resource cleanup
  • 7Open 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

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 coder:
3 image: ghcr.io/coder/coder:latest
4 container_name: coder
5 restart: unless-stopped
6 ports:
7 - "${CODER_PORT:-7080}:7080"
8 environment:
9 - CODER_PG_CONNECTION_URL=postgres://${DB_USER}:${DB_PASSWORD}@coder-db/coder?sslmode=disable
10 - CODER_HTTP_ADDRESS=0.0.0.0:7080
11 - CODER_ACCESS_URL=http://localhost:${CODER_PORT:-7080}
12 volumes:
13 - /var/run/docker.sock:/var/run/docker.sock
14 - coder_data:/home/coder/.config
15 depends_on:
16 - coder-db
17
18 coder-db:
19 image: postgres:15-alpine
20 container_name: coder-db
21 restart: unless-stopped
22 environment:
23 - POSTGRES_USER=${DB_USER}
24 - POSTGRES_PASSWORD=${DB_PASSWORD}
25 - POSTGRES_DB=coder
26 volumes:
27 - coder_db_data:/var/lib/postgresql/data
28
29volumes:
30 coder_data:
31 coder_db_data:

.env Template

.env
1# Coder
2CODER_PORT=7080
3DB_USER=coder
4DB_PASSWORD=coder_password

Usage Notes

  1. 1Coder at http://localhost:7080
  2. 2Create first user on startup
  3. 3Define workspace templates
  4. 4Docker or Kubernetes backends

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

coder
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
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

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 coder:
5 image: ghcr.io/coder/coder:latest
6 container_name: coder
7 restart: unless-stopped
8 ports:
9 - "${CODER_PORT:-7080}:7080"
10 environment:
11 - CODER_PG_CONNECTION_URL=postgres://${DB_USER}:${DB_PASSWORD}@coder-db/coder?sslmode=disable
12 - CODER_HTTP_ADDRESS=0.0.0.0:7080
13 - CODER_ACCESS_URL=http://localhost:${CODER_PORT:-7080}
14 volumes:
15 - /var/run/docker.sock:/var/run/docker.sock
16 - coder_data:/home/coder/.config
17 depends_on:
18 - coder-db
19
20 coder-db:
21 image: postgres:15-alpine
22 container_name: coder-db
23 restart: unless-stopped
24 environment:
25 - POSTGRES_USER=${DB_USER}
26 - POSTGRES_PASSWORD=${DB_PASSWORD}
27 - POSTGRES_DB=coder
28 volumes:
29 - coder_db_data:/var/lib/postgresql/data
30
31volumes:
32 coder_data:
33 coder_db_data:
34EOF
35
36# 2. Create the .env file
37cat > .env << 'EOF'
38# Coder
39CODER_PORT=7080
40DB_USER=coder
41DB_PASSWORD=coder_password
42EOF
43
44# 3. Start the services
45docker compose up -d
46
47# 4. View logs
48docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/coder-workspace-stack/run | bash

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

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space