DCA Data Analysis & Reporting 5 — Questions and Answers
Question 1: Which log driver is the default for Docker containers when no driver is explicitly configured?
- syslog
- journald
- json-file (Correct answer)
- local
Correct answer: json-file
By default, Docker uses the `json-file` log driver, storing logs as JSON on the host filesystem.
Question 2: You want `docker logs` to follow output in real time, similar to `tail -f`. Which flag do you use?
- --watch
- --stream
- --follow (Correct answer)
- --live
Correct answer: --follow
`docker logs --follow` (or `-f`) continuously streams new log output as the container produces it.
Question 3: A Swarm service is running 5 replicas. Which command retrieves aggregated logs from all replicas?
- docker logs <service_name>
- docker service logs <service_name> (Correct answer)
- docker stack logs <service_name>
- docker ps logs <service_name>
Correct answer: docker service logs <service_name>
`docker service logs` aggregates log output from all replicas of a Swarm service.
Question 4: When the `json-file` log driver is configured with `max-size=10m` and `max-file=3`, what happens when logs exceed 10MB?
- Logging stops until the file is cleared
- The container is paused
- The log file rotates and old files are deleted when count exceeds 3 (Correct answer)
- Logs are compressed in place
Correct answer: The log file rotates and old files are deleted when count exceeds 3
Docker rotates the log file at `max-size` and keeps only `max-file` rotated files, deleting the oldest.
Question 5: Which command would report the total number of images, containers, and volumes on a Docker host?
- docker ps -a
- docker image ls && docker volume ls
- docker info (Correct answer)
- docker system df
Correct answer: docker info
`docker info` provides a comprehensive summary including counts of images, containers, and volumes.
Question 6: You need to time-limit `docker events` to only show events that occurred in a specific window. Which flags accomplish this?
- --from and --to
- --start and --end
- --since and --until (Correct answer)
- --begin and --finish
Correct answer: --since and --until
`docker events --since` and `--until` bound the time range of events returned.
Question 7: Which storage location on the host holds `json-file` log driver output for a container?
- /var/log/containers/<container_id>.log
- /var/lib/docker/containers/<container_id>/<container_id>-json.log (Correct answer)
- /etc/docker/logs/<container_id>.json
- /run/docker/logs/<container_id>.log
Correct answer: /var/lib/docker/containers/<container_id>/<container_id>-json.log
The `json-file` driver writes logs to `/var/lib/docker/containers/<id>/<id>-json.log` on the host.
Which log driver is the default for Docker containers when no driver is explicitly configured?