Skip to content

Docker

The Tech Strategy Tool uses Docker Compose for infrastructure. This page covers the Docker setup, database management, and common operations.

The development infrastructure is defined in docker/docker-compose.yml:

Terminal window
docker compose -f docker/docker-compose.yml up -d

This starts a PostgreSQL 17 container with:

SettingValue
Imagepostgres:17
Port5432:5432 (host:container)
Databasetechstrat
Usernametechstrat
Passwordtechstrat_dev
Volumetechstrat-pgdata mounted at /var/lib/postgresql/data
Healthcheckpg_isready -U techstrat -d techstrat every 10s (timeout 5s, 5 retries)
Terminal window
docker compose -f docker/docker-compose.yml up -d

The -d flag runs the container in detached mode (background). The database is ready when the healthcheck passes.

To check the status:

Terminal window
docker compose -f docker/docker-compose.yml ps
Terminal window
docker compose -f docker/docker-compose.yml down

This stops and removes the container but preserves the techstrat-pgdata volume. Restarting with up -d will resume with existing data.

Terminal window
docker compose -f docker/docker-compose.yml down -v
docker compose -f docker/docker-compose.yml up -d

The -v flag removes volumes, destroying all data. The next application startup will auto-apply EF Core migrations to create the 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.

To connect to the development database directly:

Terminal window
docker compose -f docker/docker-compose.yml exec postgres psql -U techstrat -d techstrat

Or using any PostgreSQL client with the connection details in the table above.

Terminal window
docker compose -f docker/docker-compose.yml logs -f postgres

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

If another PostgreSQL instance is running on port 5432:

Terminal window
# Check what's using the port
netstat -ano | findstr :5432 # Windows
lsof -i :5432 # macOS/Linux

Either stop the conflicting service or modify the port mapping in docker-compose.yml.

Check the logs for errors:

Terminal window
docker compose -f docker/docker-compose.yml logs postgres

Common issues:

  • Port conflict — another service on port 5432
  • Disk space — Docker ran out of disk space
  • Corrupted volume — reset with down -v and up -d