DCA Data Analysis & Reporting 2 — Questions and Answers
Question 1: Which command shows real-time resource usage statistics for all running containers?
- docker ps --stats
- docker stats (Correct answer)
- docker inspect --live
- docker monitor
Correct answer: docker stats
`docker stats` streams live CPU, memory, network I/O, and block I/O metrics for running containers.
Question 2: You want to capture a single snapshot of container stats without streaming continuously. Which flag achieves this?
- --once
- --no-stream (Correct answer)
- --snapshot
- --single
Correct answer: --no-stream
`docker stats --no-stream` outputs one set of stats and exits instead of continuously streaming.
Question 3: Which `docker system` subcommand displays disk usage broken down by images, containers, and volumes?
- docker system usage
- docker system info
- docker system df (Correct answer)
- docker system inspect
Correct answer: docker system df
`docker system df` reports disk usage for images, containers, local volumes, and build cache.
Question 4: A developer needs to retrieve the last 50 log lines from a container named `api`. Which command is correct?
- docker logs --head=50 api
- docker logs --tail=50 api (Correct answer)
- docker logs -n 50 api
- docker logs --lines 50 api
Correct answer: docker logs --tail=50 api
`docker logs --tail=50 api` outputs only the last 50 lines from the container's log.
Question 5: Which log driver sends container logs directly to a syslog server?
- json-file
- gelf
- syslog (Correct answer)
- fluentd
Correct answer: syslog
The `syslog` log driver forwards container log messages to a syslog-compatible server.
Question 6: What does the `--format` flag in `docker stats` allow you to do?
- Filter containers by resource threshold
- Output stats as JSON automatically
- Customize the output columns using Go templates (Correct answer)
- Set the refresh interval
Correct answer: Customize the output columns using Go templates
`--format` accepts Go template strings to select and arrange which stats fields are displayed.
Question 7: Which Docker CLI command lists all Docker events (create, start, stop, etc.) occurring in real time?
- docker logs --events
- docker ps --watch
- docker events (Correct answer)
- docker inspect --stream
Correct answer: docker events
`docker events` streams real-time lifecycle and configuration events from the Docker daemon.
Which command shows real-time resource usage statistics for all running containers?