Embedded PostgreSQL
The default configuration uses an embedded PostgreSQL instance running inside the Anchor container. This is ideal for:- Single-server deployments
- Development and testing
- Small to medium workloads
- Simplified setup with minimal configuration
How It Works
The Anchor Docker image is built onpostgres:18-alpine and includes:
- PostgreSQL 18 database server
- Node.js runtime (for API and web services)
- Supervisord process manager
PG_HOST is empty, Anchor:
- Initializes PostgreSQL in
/data/postgres - Listens on
127.0.0.1:5432(internal only) - Runs migrations automatically
- Starts API and web services
Configuration
Data Location
All data is stored in the/data volume:
Advantages
- Simple setup: Single container, no external dependencies
- Auto-configured: Credentials and initialization handled automatically
- Resource efficient: Minimal overhead for small workloads
- Easy backups: Single volume contains everything
Limitations
- No horizontal scaling: Cannot run multiple Anchor instances
- Resource sharing: Database and application share container resources
- Limited tuning: PostgreSQL settings use container defaults
- Backup complexity: Requires container shutdown for consistent backups
External PostgreSQL
For production deployments, use a dedicated PostgreSQL server. This is ideal for:- High-availability setups
- Horizontal scaling (multiple Anchor instances)
- Managed database services (AWS RDS, Azure Database, etc.)
- Advanced database tuning and monitoring
- Easier backup and disaster recovery
Configuration
Docker Compose with External Database
PostgreSQL Version Requirements
- Minimum version: PostgreSQL 12
- Recommended: PostgreSQL 15 or 16
- Tested with: PostgreSQL 18 (embedded)
Connection String Format
Anchor constructs the connection string internally:Migration Between Modes
From Embedded to External
Set up external PostgreSQL
Create the database and user as shown in the external configuration section.
From External to Embedded
Database Maintenance
Backups
Monitoring
Performance Tuning
Embedded PostgreSQL
Limited tuning available. Increase container resources:docker-compose.yml
External PostgreSQL
Full control over PostgreSQL configuration:postgresql.conf
Troubleshooting
Connection refused errors
Migration failures
Database corruption (embedded)
Comparison Table
| Feature | Embedded PostgreSQL | External PostgreSQL |
|---|---|---|
| Setup complexity | Minimal | Moderate |
| Configuration | Auto-configured | Manual setup required |
| Container count | 1 | 2+ |
| Horizontal scaling | No | Yes |
| High availability | No | Yes (with replicas) |
| Resource isolation | Shared | Separate |
| Backup complexity | Volume backup | Standard pg_dump |
| Managed services | No | Yes (RDS, Azure, etc.) |
| Performance tuning | Limited | Full control |
| Best for | Small deployments | Production |
Next Steps
Configuration
Learn about all configuration options
Updating
Keep your instance up to date