Sentry (Self-Hosted)
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:alpine4 container_name: sentry-redis5 restart: unless-stopped6 networks: 7 - sentry-network89 postgres: 10 image: postgres:15-alpine11 container_name: sentry-postgres12 restart: unless-stopped13 environment: 14 POSTGRES_USER: sentry15 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}16 POSTGRES_DB: sentry17 volumes: 18 - postgres_data:/var/lib/postgresql/data19 networks: 20 - sentry-network2122 sentry: 23 image: getsentry/sentry:latest24 container_name: sentry25 restart: unless-stopped26 environment: 27 SENTRY_SECRET_KEY: ${SENTRY_SECRET_KEY}28 SENTRY_POSTGRES_HOST: postgres29 SENTRY_DB_USER: sentry30 SENTRY_DB_PASSWORD: ${POSTGRES_PASSWORD}31 SENTRY_REDIS_HOST: redis32 ports: 33 - "9000:9000"34 depends_on: 35 - redis36 - postgres37 networks: 38 - sentry-network3940volumes: 41 postgres_data: 4243networks: 44 sentry-network: 45 driver: bridge.env Template
.env
1POSTGRES_PASSWORD=changeme2SENTRY_SECRET_KEY=your-secret-key-hereUsage Notes
- 1Docs: https://develop.sentry.dev/self-hosted/
- 2UI at http://localhost:9000 after setup completes
- 3Run: docker compose run --rm sentry upgrade (creates DB + superuser)
- 4Generate SECRET_KEY: openssl rand -hex 32
- 5Install Sentry SDKs in your apps to capture errors
- 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 file2cat > docker-compose.yml << 'EOF'3services:4 redis:5 image: redis:alpine6 container_name: sentry-redis7 restart: unless-stopped8 networks:9 - sentry-network1011 postgres:12 image: postgres:15-alpine13 container_name: sentry-postgres14 restart: unless-stopped15 environment:16 POSTGRES_USER: sentry17 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}18 POSTGRES_DB: sentry19 volumes:20 - postgres_data:/var/lib/postgresql/data21 networks:22 - sentry-network2324 sentry:25 image: getsentry/sentry:latest26 container_name: sentry27 restart: unless-stopped28 environment:29 SENTRY_SECRET_KEY: ${SENTRY_SECRET_KEY}30 SENTRY_POSTGRES_HOST: postgres31 SENTRY_DB_USER: sentry32 SENTRY_DB_PASSWORD: ${POSTGRES_PASSWORD}33 SENTRY_REDIS_HOST: redis34 ports:35 - "9000:9000"36 depends_on:37 - redis38 - postgres39 networks:40 - sentry-network4142volumes:43 postgres_data:4445networks:46 sentry-network:47 driver: bridge48EOF4950# 2. Create the .env file51cat > .env << 'EOF'52POSTGRES_PASSWORD=changeme53SENTRY_SECRET_KEY=your-secret-key-here54EOF5556# 3. Start the services57docker compose up -d5859# 4. View logs60docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/sentry/run | bashTroubleshooting
- 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
Components
sentryredispostgreskafka
Tags
#sentry#error-tracking#performance#debugging#apm
Category
Monitoring & ObservabilityAd Space
Shortcuts: C CopyF FavoriteD Download