Challenge - 5 Problems
Docker Logs Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Identify the output of a Docker logs command
You run the command
docker logs myapp on a container named myapp. What will you see if the container has just started and printed Hello World once?Attempts:
2 left
💡 Hint
Think about what
docker logs shows from the container's output.✗ Incorrect
The docker logs command shows the standard output and error streams from the container. If the container printed Hello World, that text will appear.
🧠 Conceptual
intermediate1:30remaining
Understanding Docker logs options
Which docker logs option allows you to continuously stream new log output as it is generated?
Attempts:
2 left
💡 Hint
This option is like watching a live feed of logs.
✗ Incorrect
The --follow option streams logs live, similar to tail -f in Linux.
❓ Troubleshoot
advanced2:00remaining
Diagnosing missing logs from a container
You run
docker logs myservice but see no output, even though the container is running and should produce logs. What is the most likely cause?Attempts:
2 left
💡 Hint
Think about Docker's logging drivers and how they affect log availability.
✗ Incorrect
If the container was started with the none log driver, Docker does not store logs, so docker logs shows nothing.
🔀 Workflow
advanced2:30remaining
Steps to troubleshoot a failing container using logs
Arrange the steps in the correct order to troubleshoot a container that fails immediately after starting using Docker logs.
Attempts:
2 left
💡 Hint
Start by checking if the container is running before looking at logs.
✗ Incorrect
First, verify the container status with docker ps. Then check logs for errors. Next, inspect the exit code to understand failure cause. Finally, fix and restart.
✅ Best Practice
expert3:00remaining
Choosing the best logging driver for troubleshooting
You want to ensure your Docker containers' logs are easily accessible and include timestamps for troubleshooting. Which logging driver and option combination is best?
Attempts:
2 left
💡 Hint
Consider default drivers and how to add timestamps.
✗ Incorrect
The json-file driver is Docker's default and supports timestamps=true to add timestamps to logs, making troubleshooting easier.