docker.recipes

Sentry (Self-Hosted)

advanced

Error tracking and performance monitoring platform.

Overview

Sentry is an open-source application monitoring and error tracking platform that helps developers identify, debug, and resolve issues in production applications. Originally developed by Disqus in 2008 and later spun off as an independent company, Sentry has become the de facto standard for error tracking, offering both cloud-hosted and self-hosted solutions. The platform excels at capturing exceptions, tracking performance bottlenecks, and providing detailed context through features like breadcrumbs, stack traces, and session replay. This Docker deployment creates a complete self-hosted Sentry installation using three essential services: the main Sentry application server, PostgreSQL for persistent data storage of events and configuration, and Redis for caching and background task processing. The Sentry container handles all web interface functionality, event processing, and API endpoints, while leveraging PostgreSQL for reliable data persistence and Redis for high-performance caching and job queues. This configuration is ideal for organizations requiring data sovereignty, custom integrations, or cost control for high-volume error tracking. Self-hosted Sentry provides the same powerful error tracking and performance monitoring capabilities as the SaaS version, but requires significant technical expertise and resources to maintain. It's particularly valuable for enterprises with strict data residency requirements, teams processing millions of events monthly, or organizations needing extensive customization of the monitoring platform.

Key Features

  • Real-time error tracking with automatic grouping and deduplication of similar issues
  • Performance monitoring with transaction tracing and database query analysis
  • Release tracking with deployment markers and regression detection
  • Breadcrumbs providing detailed context leading up to errors
  • Source map support for debugging minified JavaScript in production
  • Alert rules with integrations to Slack, email, PagerDuty, and webhook endpoints
  • Team-based access control with project-level permissions and role management
  • Custom dashboards and metric extraction from error and performance data

Common Use Cases

  • 1Enterprise applications requiring on-premises deployment for data compliance and security
  • 2High-volume applications processing millions of errors monthly to avoid SaaS pricing
  • 3Development teams needing custom integrations with internal tools and workflows
  • 4Organizations in regulated industries requiring full control over error data storage
  • 5Multi-tenant SaaS platforms wanting to offer error tracking as a white-labeled service
  • 6Companies with strict data residency requirements preventing cloud-hosted solutions
  • 7DevOps teams managing microservices architectures requiring centralized error aggregation

Prerequisites

  • Minimum 4GB RAM and 2 CPU cores for handling Sentry's resource-intensive event processing
  • Docker and Docker Compose installed with at least 10GB available disk space
  • Generated SENTRY_SECRET_KEY using openssl rand -hex 32 for session security
  • Strong PostgreSQL password set in POSTGRES_PASSWORD environment variable
  • Port 9000 available for Sentry web interface access
  • Understanding of Sentry SDK integration for instrumenting applications

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 redis:
3 image: redis:alpine
4 container_name: sentry-redis
5 restart: unless-stopped
6 networks:
7 - sentry-network
8
9 postgres:
10 image: postgres:15-alpine
11 container_name: sentry-postgres
12 restart: unless-stopped
13 environment:
14 POSTGRES_USER: sentry
15 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
16 POSTGRES_DB: sentry
17 volumes:
18 - postgres_data:/var/lib/postgresql/data
19 networks:
20 - sentry-network
21
22 sentry:
23 image: getsentry/sentry:latest
24 container_name: sentry
25 restart: unless-stopped
26 environment:
27 SENTRY_SECRET_KEY: ${SENTRY_SECRET_KEY}
28 SENTRY_POSTGRES_HOST: postgres
29 SENTRY_DB_USER: sentry
30 SENTRY_DB_PASSWORD: ${POSTGRES_PASSWORD}
31 SENTRY_REDIS_HOST: redis
32 ports:
33 - "9000:9000"
34 depends_on:
35 - redis
36 - postgres
37 networks:
38 - sentry-network
39
40volumes:
41 postgres_data:
42
43networks:
44 sentry-network:
45 driver: bridge

.env Template

.env
1POSTGRES_PASSWORD=changeme
2SENTRY_SECRET_KEY=your-secret-key-here

Usage Notes

  1. 1Docs: https://develop.sentry.dev/self-hosted/
  2. 2UI at http://localhost:9000 after setup completes
  3. 3Run: docker compose run --rm sentry upgrade (creates DB + superuser)
  4. 4Generate SECRET_KEY: openssl rand -hex 32
  5. 5Install Sentry SDKs in your apps to capture errors
  6. 6Self-hosted requires significant resources - use SaaS for small teams

Individual Services(3 services)

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

redis
redis:
  image: redis:alpine
  container_name: sentry-redis
  restart: unless-stopped
  networks:
    - sentry-network
postgres
postgres:
  image: postgres:15-alpine
  container_name: sentry-postgres
  restart: unless-stopped
  environment:
    POSTGRES_USER: sentry
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    POSTGRES_DB: sentry
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - sentry-network
sentry
sentry:
  image: getsentry/sentry:latest
  container_name: sentry
  restart: unless-stopped
  environment:
    SENTRY_SECRET_KEY: ${SENTRY_SECRET_KEY}
    SENTRY_POSTGRES_HOST: postgres
    SENTRY_DB_USER: sentry
    SENTRY_DB_PASSWORD: ${POSTGRES_PASSWORD}
    SENTRY_REDIS_HOST: redis
  ports:
    - "9000:9000"
  depends_on:
    - redis
    - postgres
  networks:
    - sentry-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 redis:
5 image: redis:alpine
6 container_name: sentry-redis
7 restart: unless-stopped
8 networks:
9 - sentry-network
10
11 postgres:
12 image: postgres:15-alpine
13 container_name: sentry-postgres
14 restart: unless-stopped
15 environment:
16 POSTGRES_USER: sentry
17 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
18 POSTGRES_DB: sentry
19 volumes:
20 - postgres_data:/var/lib/postgresql/data
21 networks:
22 - sentry-network
23
24 sentry:
25 image: getsentry/sentry:latest
26 container_name: sentry
27 restart: unless-stopped
28 environment:
29 SENTRY_SECRET_KEY: ${SENTRY_SECRET_KEY}
30 SENTRY_POSTGRES_HOST: postgres
31 SENTRY_DB_USER: sentry
32 SENTRY_DB_PASSWORD: ${POSTGRES_PASSWORD}
33 SENTRY_REDIS_HOST: redis
34 ports:
35 - "9000:9000"
36 depends_on:
37 - redis
38 - postgres
39 networks:
40 - sentry-network
41
42volumes:
43 postgres_data:
44
45networks:
46 sentry-network:
47 driver: bridge
48EOF
49
50# 2. Create the .env file
51cat > .env << 'EOF'
52POSTGRES_PASSWORD=changeme
53SENTRY_SECRET_KEY=your-secret-key-here
54EOF
55
56# 3. Start the services
57docker compose up -d
58
59# 4. View logs
60docker 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/sentry/run | bash

Troubleshooting

  • Sentry container fails to start: Run 'docker compose run --rm sentry upgrade' to initialize the database and create superuser account
  • Out of memory errors during event processing: Increase Docker memory limit to at least 4GB and consider adding swap space
  • PostgreSQL connection refused: Verify postgres container is healthy and SENTRY_DB_PASSWORD matches POSTGRES_PASSWORD environment variable
  • Redis connection timeouts: Check redis container logs for memory issues and consider increasing Redis memory limits
  • Sentry web interface shows 500 errors: Check database migrations completed successfully and SECRET_KEY is properly set
  • High disk usage from PostgreSQL: Implement event retention policies through Sentry admin interface and consider database cleanup jobs

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