Skip to content

Docker

The Tech Strategy Tool uses Docker Compose to run PostgreSQL for development. The .NET application runs directly on the host — there is no Dockerfile or app container. This page covers the Docker setup, database management, and common operations.

Docker Compose Configuration

The development infrastructure is defined in docker/docker-compose.yml. It contains a single service:

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

This 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)

No other services are defined — no Redis, no message broker, no app container.

Starting the Database

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:

docker compose -f docker/docker-compose.yml ps

Stopping the Database

Stop (preserve data)

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.

Stop and reset data

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.

Data loss

Using down -v permanently deletes all events, checkpoints, users, and sessions. This is useful for development resets but should never be done in a production environment.

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

To connect to the development database directly:

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.

Viewing Logs

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

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

Port 5432 already in use

If another PostgreSQL instance is running on port 5432:

# 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.

Container fails to start

Check the logs for errors:

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