Docker
The Tech Strategy Tool uses Docker Compose for infrastructure. This page covers the Docker setup, database management, and common operations.
Docker Compose Configuration
Section titled “Docker Compose Configuration”The development infrastructure is defined in docker/docker-compose.yml:
docker compose -f docker/docker-compose.yml up -dThis starts a PostgreSQL 17 container with:
| Setting | Value |
|---|---|
| Image | postgres:17 |
| Port | 5432:5432 (host:container) |
| Database | techstrat |
| Username | techstrat |
| Password | techstrat_dev |
| Volume | techstrat-pgdata mounted at /var/lib/postgresql/data |
| Healthcheck | pg_isready -U techstrat -d techstrat every 10s (timeout 5s, 5 retries) |
Starting the Database
Section titled “Starting the Database”docker compose -f docker/docker-compose.yml up -dThe -d flag runs the container in detached mode (background). The database is ready when the healthcheck passes.
To check the status:
docker compose -f docker/docker-compose.yml psStopping the Database
Section titled “Stopping the Database”Stop (preserve data)
Section titled “Stop (preserve data)”docker compose -f docker/docker-compose.yml downThis stops and removes the container but preserves the techstrat-pgdata volume. Restarting with up -d will resume with existing data.
Stop and reset data
Section titled “Stop and reset data”docker compose -f docker/docker-compose.yml down -vdocker compose -f docker/docker-compose.yml up -dThe -v flag removes volumes, destroying all data. The next application startup will auto-apply EF Core migrations to create the schema.
Database Schema
Section titled “Database Schema”EF Core migrations are the sole source of truth for the database schema. In Development mode, migrations are auto-applied on application startup via db.Database.MigrateAsync(). A fresh Docker container starts with an empty database — the application creates all tables and indexes automatically on first run.
See Migrations for schema management details.
Connecting to the Database
Section titled “Connecting to the Database”To connect to the development database directly:
docker compose -f docker/docker-compose.yml exec postgres psql -U techstrat -d techstratOr using any PostgreSQL client with the connection details in the table above.
Viewing Logs
Section titled “Viewing Logs”docker compose -f docker/docker-compose.yml logs -f postgresIntegration Tests
Section titled “Integration Tests”Integration tests (TechStrat.Api.Tests and TechStrat.Infrastructure.Tests) use Testcontainers to spin up isolated PostgreSQL instances automatically. They do not use the development Docker Compose database.
This means:
- You can run integration tests while the dev database is running
- Tests are isolated and do not affect dev data
- Docker must be running for integration tests to work
Troubleshooting
Section titled “Troubleshooting”Port 5432 already in use
Section titled “Port 5432 already in use”If another PostgreSQL instance is running on port 5432:
# Check what's using the portnetstat -ano | findstr :5432 # Windowslsof -i :5432 # macOS/LinuxEither stop the conflicting service or modify the port mapping in docker-compose.yml.
Container fails to start
Section titled “Container fails to start”Check the logs for errors:
docker compose -f docker/docker-compose.yml logs postgresCommon issues:
- Port conflict — another service on port 5432
- Disk space — Docker ran out of disk space
- Corrupted volume — reset with
down -vandup -d