Docker Compose Setup¶
The Docker Compose stack requires only Docker Desktop — no .NET SDK, PostgreSQL, or Python needed locally. It's also the setup used in CI.
Start the full stack¶
This starts three services in order:
postgres:16-alpine ← starts first, health-checked
mock-api (Flask) ← starts after postgres is healthy
backend (.NET) ← starts last; runs EF migrations, then app
The backend entrypoint (docker/scripts/backend-entrypoint.sh):
- Waits for
pg_isready - Runs
dotnet ef database update --context CoreDbContext - Runs
dotnet ef database update --context MeeshoDbContext - Seeds
API_Base_URL=http://mock-api:5000into the DB - Starts the .NET application
Verify¶
make docker-smoke
# or manually:
curl http://localhost:5269/health
curl http://localhost:5000/health
Open http://localhost:5269/swagger for the full API explorer.
Common Docker commands¶
# Stream all service logs
docker compose logs -f
# Stream one service
docker compose logs -f backend
docker compose logs -f mock-api
docker compose logs -f postgres
# Shell access
docker compose exec backend bash
docker compose exec postgres psql -U postgres -d dms-layered
# Restart a single service (e.g. after code change)
docker compose restart backend
# Rebuild one service
docker compose build backend
# Stop (preserves database volume)
docker compose down
# Stop + wipe database
docker compose down -v
# Full reset (rebuild from scratch)
docker compose down -v && docker compose up -d --build
Connection strings inside Docker¶
Inside the Docker network, services communicate using their service names, not localhost:
| From | To | Host to use |
|---|---|---|
| backend | postgres | Server=postgres;Port=5432 |
| backend | mock-api | http://mock-api:5000 |
| your browser | backend | http://localhost:5269 |
| your browser | mock-api | http://localhost:5000 |
docker-compose.yml injects ConnectionStrings__DefaultConnection with Server=postgres via environment variable — the appsettings.json value (Server=localhost) is overridden inside Docker. No file changes needed.