Local vs Docker Databases
Choose where your database runs and configure DATABASE_URL correctly.
When running Tzylo Auth CE, one of the first decisions you make is where your database should run.
There is no single correct choice. The right setup depends on your development workflow and deployment environment.
Common database setups
- Database running locally on your machine
- Database running in Docker
- Database running in Docker Compose with Auth CE
Database running locally
In this setup, the database runs directly on your machine (for example via a local Postgres or MySQL installation).
This is common during early development.
Auth CE running locally
If both Auth CE and the database run on your machine, use localhost :
DATABASE_URL=postgresql://user:pass@localhost:5432/authdbAuth CE running in Docker
If Auth CE runs inside Docker and the database runs on your machine, localhost will not work.
Use host.docker.internal instead:
DATABASE_URL=postgresql://user:pass@host.docker.internal:5432/authdbDatabase running in Docker
In this setup, the database runs in a Docker container.
This avoids installing database software directly on your machine and keeps environments consistent.
Database container with exposed port
If the database container exposes a port, and Auth CE runs locally, you can still use localhost:
DATABASE_URL=postgresql://user:pass@localhost:5432/authdbDocker forwards the container port to your machine.
Both services in Docker Compose
This is the recommended setup for most projects.
When using Docker Compose, services communicate using service names:
DATABASE_URL=postgresql://auth:auth@db:5432/authdbHere, db is the database service name indocker-compose.yml.
localhost between services in Docker Compose.Which setup should you use?
- Local DB – fast iteration, simple setup
- Docker DB – consistent environments, easier cleanup
- Compose – closest to production, recommended long-term
Common mistakes
- Using
localhostinside Docker - Forgetting to expose database ports
- Mismatched database credentials
- Assuming Docker Compose uses the host network