You may have to switch to version: 3 to do this, I believe on version: 2 you can use the “scale” parameter but I’m not 100% sure.
Anyways, you can override the “replicas” parameter like this:
# docker-compose.prod.yml
version: "3"
services:
db_for_development:
deploy:
replicas: 0