When running docker-compose up, only one db container starts. Why?
medium
A. The 'deploy' section is ignored by 'docker-compose up'.
B. You must specify replicas in 'docker-compose up' command.
C. Postgres image does not support multiple replicas.
D. Port mapping conflicts prevent multiple containers.
Solution
Step 1: Understand 'deploy' section scope
The 'deploy' key is only used by Docker Swarm, not by 'docker-compose up'.
Step 2: Explain why only one container starts
'docker-compose up' ignores 'deploy', so it starts one container by default.
Final Answer:
The 'deploy' section is ignored by 'docker-compose up'. -> Option A
Quick Check:
'deploy' ignored by 'docker-compose up' = one container [OK]
Hint: 'deploy' works only with Swarm, not 'docker-compose up' [OK]
Common Mistakes:
Thinking 'docker-compose up' can scale with 'deploy'
Assuming port conflicts cause single container
Believing image limits replicas
5. You want to deploy a web app with a database using Docker Compose. You need to: - Scale the web service to 4 instances - Limit each web container to 1 CPU and 1GB RAM - Ensure the database runs only once with persistent storage
Which Compose features help you achieve this setup?
hard
A. Use 'deploy.replicas' and 'deploy.resources.limits' for web; use volumes for DB persistence.
B. Use 'scale' in 'docker-compose up' for DB; use 'deploy' for web resource limits.
C. Use environment variables to limit CPU and RAM; scale DB with 'deploy.replicas'.
D. Use 'depends_on' to scale web; use 'ports' to limit DB resources.
Solution
Step 1: Identify scaling and resource control for web
Use 'deploy.replicas' to scale web to 4 and 'deploy.resources.limits' to limit CPU and RAM.
Step 2: Ensure single DB instance with persistence
Set DB replicas to 1 and use volumes to keep data persistent.
Final Answer:
Use 'deploy.replicas' and 'deploy.resources.limits' for web; use volumes for DB persistence. -> Option A
Quick Check:
Scaling + resource limits + volumes = Use 'deploy.replicas' and 'deploy.resources.limits' for web; use volumes for DB persistence. [OK]
Hint: 'deploy' controls scale and limits; volumes keep DB data safe [OK]
Common Mistakes:
Trying to scale DB instead of web
Using environment variables for resource limits
Confusing 'depends_on' with scaling or resource control
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.