Problem
docker compose -f docker-compose.dev.yml up --scale rest-api=2 cannot run. The rest-api service sets a fixed container_name and binds a fixed host port 4000:4000. A container name must be unique, and a host port cannot bind twice.
This matters because production runs rest-api with replicas: 2 and no sticky session, so any state held per process is invisible in development and breaks in production.
What to do
Remove container_name from the rest-api service, and change the fixed port binding so more than one replica can start. A port range, or dropping the host binding and reaching the service through the network, both work.
Leave the other services alone.
Acceptance
Notes
There is a cheaper workaround for the specific case that found this: two processes on two ports, APP_PORT=4001 bun src/index.ts and APP_PORT=4002 bun src/index.ts. Two processes are two memories, which is the production condition. #226 uses that workaround for its stateless test.
So this issue is only worth doing if someone needs real container scaling in development.
Problem
docker compose -f docker-compose.dev.yml up --scale rest-api=2cannot run. Therest-apiservice sets a fixedcontainer_nameand binds a fixed host port4000:4000. A container name must be unique, and a host port cannot bind twice.This matters because production runs
rest-apiwithreplicas: 2and no sticky session, so any state held per process is invisible in development and breaks in production.What to do
Remove
container_namefrom therest-apiservice, and change the fixed port binding so more than one replica can start. A port range, or dropping the host binding and reaching the service through the network, both work.Leave the other services alone.
Acceptance
docker compose -f docker-compose.dev.yml up --scale rest-api=2starts two containers.Notes
There is a cheaper workaround for the specific case that found this: two processes on two ports,
APP_PORT=4001 bun src/index.tsandAPP_PORT=4002 bun src/index.ts. Two processes are two memories, which is the production condition. #226 uses that workaround for its stateless test.So this issue is only worth doing if someone needs real container scaling in development.