This guide explains how to set up Postgres using Docker Compose for local development.
Note: The primary local development path uses Supabase CLI (
supabase start), which spins up a full Supabase stack including Postgres. Use this Docker Compose setup as a lightweight alternative when you don't need the full Supabase stack.
-
Copy environment file:
cp .docker.env.example .docker.env
-
Edit
.docker.env(optional - defaults will work):# Update passwords and settings as needed -
Start Postgres:
docker-compose up -d
-
Verify it's running:
docker-compose ps
-
Connect to database:
# Using psql client psql -h 127.0.0.1 -p 5432 -U postgres -d bishop_state # Or using Docker docker-compose exec postgres psql -U postgres -d bishop_state
- Port: 5432 (default)
- Database:
bishop_state - User:
postgres(default) - Password:
devcolor2025(default, change in.docker.env)
- Port: 8080 (default)
- URL: http://localhost:8080
- Email:
admin@bishopstate.edu(default) - Password:
devcolor2025(default)
To connect pgAdmin to the Postgres container, add a new server with:
- Host:
postgres(the Docker service name) - Port:
5432 - Username:
postgres - Password:
devcolor2025
Database data is stored in a Docker volume named postgres_data. This means:
- Data persists even if you stop/remove the container
- Data is shared across container restarts
- To remove all data:
docker-compose down -v
SQL files in database_dumps/ are automatically executed on first startup (when the database is empty). Files run in alphabetical order.
Note: The database_dumps/ directory is mounted as read-only.
All configuration is in .docker.env:
| Variable | Default | Description |
|---|---|---|
POSTGRES_USER |
postgres |
Database user |
POSTGRES_PASSWORD |
devcolor2025 |
Database password |
POSTGRES_DB |
bishop_state |
Database name |
POSTGRES_PORT |
5432 |
Host port mapping |
PGADMIN_EMAIL |
admin@bishopstate.edu |
pgAdmin login email |
PGADMIN_PASSWORD |
devcolor2025 |
pgAdmin login password |
PGADMIN_PORT |
8080 |
pgAdmin port |
docker-compose up -ddocker-compose stopdocker-compose downdocker-compose down -vdocker-compose logs -f postgresdocker-compose exec postgres psql -U postgres -d bishop_statedocker-compose exec postgres pg_dump -U postgres bishop_state > backup.sqldocker-compose exec -T postgres psql -U postgres -d bishop_state < backup.sqlUpdate your operations/db_config.py or .env file:
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=devcolor2025
DB_PORT=5432
DB_NAME=bishop_stateUpdate codebenders-dashboard/.env.local:
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=devcolor2025
DB_PORT=5432
DB_NAME=bishop_state
DB_SSL=falseIf port 5432 is already in use (e.g., local Postgres or Supabase is running), change POSTGRES_PORT in .docker.env:
POSTGRES_PORT=5433Then update your connection strings to use port 5433.
Make sure Docker has permission to access the database_dumps/ directory:
chmod -R 755 database_dumps/Check logs:
docker-compose logs postgresdocker-compose down -v
docker-compose up -dThe Postgres container includes a health check via pg_isready. Verify it's healthy:
docker-compose psYou should see healthy status for the postgres service.
- Use strong, unique passwords
- Don't expose ports publicly
- Use environment variables or secrets management
- Consider using Docker secrets for production
- Postgres Docker Image
- Docker Compose Documentation
- pgAdmin Documentation
- Supabase CLI (primary local dev path)