DCA Financial Management & Budgeting 2 — Questions and Answers
Question 1: A DevOps team wants to prevent a single container from consuming all available memory on a host. Which Docker run flag enforces a hard memory limit?
- --memory-reservation
- --memory (Correct answer)
- --memory-swap
- --kernel-memory
Correct answer: --memory
The --memory flag sets a hard limit on the maximum RAM a container can use.
Question 2: Your organization runs Docker containers on AWS EC2 instances. Which approach best reduces infrastructure costs when workloads are unpredictable?
- Use On-Demand instances exclusively
- Use Spot Instances with Docker Swarm for fault-tolerant services (Correct answer)
- Disable resource limits to maximize instance utilization
- Run all containers on a single large instance
Correct answer: Use Spot Instances with Docker Swarm for fault-tolerant services
Spot Instances are significantly cheaper and Docker Swarm can reschedule containers when spots are reclaimed.
Question 3: Which Docker command shows real-time resource consumption (CPU, memory, I/O) for all running containers to help identify cost-driving processes?
- docker inspect
- docker stats (Correct answer)
- docker top
- docker events
Correct answer: docker stats
docker stats streams live resource usage metrics for all running containers by default.
Question 4: A container is configured with --memory=512m --memory-swap=512m. What does this configuration imply about swap usage?
- The container can use 512m of swap in addition to RAM
- The container cannot use any swap memory (Correct answer)
- The container uses 1GB total including swap
- Swap is disabled only when memory is exhausted
Correct answer: The container cannot use any swap memory
When --memory-swap equals --memory, the container is not allowed to use any swap space.
Question 5: Which Docker resource constraint flag limits the proportion of CPU cycles a container can use relative to other containers?
- --cpus
- --cpu-shares (Correct answer)
- --cpu-period
- --cpuset-cpus
Correct answer: --cpu-shares
--cpu-shares sets a relative weight for CPU scheduling when multiple containers compete for CPU time.
Question 6: Your team builds Docker images frequently and wants to reduce registry storage costs. Which image management practice is most effective?
- Tag all images as latest only
- Implement image tag retention policies and delete unused image versions (Correct answer)
- Store all images locally instead of in a registry
- Compress images manually before pushing
Correct answer: Implement image tag retention policies and delete unused image versions
Tag retention policies automatically delete old image versions from registries, directly reducing storage billing.
Question 7: To reduce storage costs, a team wants to automatically remove stopped containers and dangling images. Which single command accomplishes this?
- docker rm --all && docker rmi --dangling
- docker system prune (Correct answer)
- docker container prune --volumes
- docker image prune -a
Correct answer: docker system prune
docker system prune removes stopped containers, dangling images, unused networks, and optionally volumes in one command.
A DevOps team wants to prevent a single container from consuming all available memory on a host.
Which Docker run flag enforces a hard memory limit?