When Docker Compose services communicate over the internal bridge network, they use the container port (e.g. db:5432), not the host-mapped port (e.g. localhost:5433). Host port mappings (ports: directive) only matter for host-side access.
This means:
- A test runner container that talks to
db:5432over the Docker network does NOT need the host port to be free - Port conflict checks before
docker compose upshould only check ports that the host-side consumer needs (e.g. Playwright hittinglocalhost:8081) - If another worktree binds the same host ports, containers that only use internal networking are unaffected — but
docker compose upwill still fail trying to bind the host port on dependency services
The fix for the last point is a compose override file that strips ports: from services that don't need host access in the test context.