docker.recipes

Coder + PostgreSQL

intermediate

Self-hosted remote development environments.

Overview

Coder is an open-source platform that provisions secure, standardized development environments in your cloud or datacenter. Originally developed to solve the challenges of remote development and developer onboarding, Coder creates consistent, reproducible workspaces that developers can access from anywhere using their favorite IDEs like VS Code, JetBrains, or vim. Unlike traditional local development setups, Coder workspaces run on powerful cloud infrastructure while maintaining the familiar development experience. This stack combines Coder's workspace orchestration with PostgreSQL as the backend database, creating a production-ready remote development platform. PostgreSQL stores all workspace metadata, user sessions, audit logs, and template configurations with the reliability and ACID compliance that enterprise development teams require. The database handles complex queries for workspace analytics, user permissions, and resource tracking across potentially hundreds of concurrent development environments. Development teams transitioning to remote work, organizations with complex onboarding processes, and companies managing developers across multiple projects will find this combination invaluable. Coder eliminates 'works on my machine' problems by standardizing development environments, while PostgreSQL ensures that workspace state, user data, and audit trails are preserved with enterprise-grade reliability. This is particularly powerful for teams working with resource-intensive applications, legacy codebases, or strict security requirements where local development isn't feasible.

Key Features

  • Template-based workspace provisioning with Terraform for consistent development environments across teams
  • IDE-agnostic development supporting VS Code, JetBrains IDEs, vim, and web-based terminals
  • Resource quotas and automatic workspace shutdown to control cloud infrastructure costs
  • Built-in SSH and port forwarding for secure access to development services and databases
  • Workspace sharing and collaboration features for pair programming and code reviews
  • PostgreSQL-backed audit logging with full ACID compliance for enterprise compliance requirements
  • Git integration with automatic repository cloning and credential management
  • Container and VM workspace support through Docker and Kubernetes providers

Common Use Cases

  • 1Remote development teams needing consistent environments across macOS, Windows, and Linux developers
  • 2Onboarding new developers with pre-configured workspaces containing all necessary tools and dependencies
  • 3Companies with complex development stacks requiring GPU access, large datasets, or specialized hardware
  • 4Organizations with strict security policies requiring air-gapped or controlled development environments
  • 5Consulting firms managing multiple client projects with different technology stacks and access requirements
  • 6Educational institutions providing standardized programming environments for computer science courses
  • 7Open source projects enabling contributors to start coding immediately without complex local setup

Prerequisites

  • Docker Engine with access to Docker socket for workspace container management
  • Minimum 4GB RAM available (2GB for Coder, 1GB for PostgreSQL, 1GB for workspace overhead)
  • Port 7080 available for Coder web interface access
  • Basic understanding of Terraform for creating custom workspace templates
  • PostgreSQL knowledge for database maintenance and backup procedures
  • Network access to container registries for pulling workspace images

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 environment:
5 - CODER_PG_CONNECTION_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/coder?sslmode=disable
6 - CODER_HTTP_ADDRESS=0.0.0.0:7080
7 - CODER_ACCESS_URL=http://localhost:7080
8 volumes:
9 - /var/run/docker.sock:/var/run/docker.sock
10 - coder-data:/home/coder/.config
11 ports:
12 - "7080:7080"
13 depends_on:
14 - postgres
15 networks:
16 - coder-network
17 restart: unless-stopped
18
19 postgres:
20 image: postgres:15
21 environment:
22 - POSTGRES_USER=${POSTGRES_USER}
23 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
24 - POSTGRES_DB=coder
25 volumes:
26 - postgres-data:/var/lib/postgresql/data
27 networks:
28 - coder-network
29 restart: unless-stopped
30
31volumes:
32 coder-data:
33 postgres-data:
34
35networks:
36 coder-network:
37 driver: bridge

.env Template

.env
1# Coder
2POSTGRES_USER=coder
3POSTGRES_PASSWORD=secure_postgres_password
4
5# Create first user: coder server create-admin-user

Usage Notes

  1. 1Web UI at http://localhost:7080
  2. 2Create admin on first run
  3. 3Templates for workspaces
  4. 4Docker, Kubernetes providers
  5. 5VS Code integration

Individual Services(2 services)

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

coder
coder:
  image: ghcr.io/coder/coder:latest
  environment:
    - CODER_PG_CONNECTION_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/coder?sslmode=disable
    - CODER_HTTP_ADDRESS=0.0.0.0:7080
    - CODER_ACCESS_URL=http://localhost:7080
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - coder-data:/home/coder/.config
  ports:
    - "7080:7080"
  depends_on:
    - postgres
  networks:
    - coder-network
  restart: unless-stopped
postgres
postgres:
  image: postgres:15
  environment:
    - POSTGRES_USER=${POSTGRES_USER}
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    - POSTGRES_DB=coder
  volumes:
    - postgres-data:/var/lib/postgresql/data
  networks:
    - coder-network
  restart: unless-stopped

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 environment:
7 - CODER_PG_CONNECTION_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/coder?sslmode=disable
8 - CODER_HTTP_ADDRESS=0.0.0.0:7080
9 - CODER_ACCESS_URL=http://localhost:7080
10 volumes:
11 - /var/run/docker.sock:/var/run/docker.sock
12 - coder-data:/home/coder/.config
13 ports:
14 - "7080:7080"
15 depends_on:
16 - postgres
17 networks:
18 - coder-network
19 restart: unless-stopped
20
21 postgres:
22 image: postgres:15
23 environment:
24 - POSTGRES_USER=${POSTGRES_USER}
25 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
26 - POSTGRES_DB=coder
27 volumes:
28 - postgres-data:/var/lib/postgresql/data
29 networks:
30 - coder-network
31 restart: unless-stopped
32
33volumes:
34 coder-data:
35 postgres-data:
36
37networks:
38 coder-network:
39 driver: bridge
40EOF
41
42# 2. Create the .env file
43cat > .env << 'EOF'
44# Coder
45POSTGRES_USER=coder
46POSTGRES_PASSWORD=secure_postgres_password
47
48# Create first user: coder server create-admin-user
49EOF
50
51# 3. Start the services
52docker compose up -d
53
54# 4. View logs
55docker 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/run | bash

Troubleshooting

  • Coder fails to connect to PostgreSQL: Verify POSTGRES_USER and POSTGRES_PASSWORD environment variables match between services
  • Workspaces fail to start with 'docker socket permission denied': Ensure Docker socket has proper permissions or add coder user to docker group
  • Template builds timeout or fail: Check Docker daemon resources and increase build timeout in Coder admin settings
  • Users can't access workspace ports: Configure CODER_ACCESS_URL to match your actual domain/IP instead of localhost
  • PostgreSQL connection pool exhausted: Increase max_connections in PostgreSQL config or reduce concurrent workspace limits
  • Workspace data lost after container restart: Verify coder-data volume is properly mounted and persistent

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