Recall & Review
beginner
What is the purpose of the
docker logs command?The
docker logs command shows the output (logs) of a running or stopped container. It helps to see what happened inside the container for troubleshooting.Click to reveal answer
beginner
How do you view the last 10 lines of logs from a Docker container named
webapp?Use the command
docker logs --tail 10 webapp. It shows only the last 10 lines of the container's logs.Click to reveal answer
beginner
What does the
-f or --follow option do in docker logs?The
-f option streams the logs live, like watching a live feed. It shows new log lines as they appear in real time.Click to reveal answer
intermediate
How can you view logs with timestamps using
docker logs?Add the
--timestamps option to the command, like docker logs --timestamps container_name. This shows when each log line was created.Click to reveal answer
beginner
Why is checking Docker logs important for troubleshooting?
Logs show what the container is doing or errors it encounters. They help find problems like crashes, misconfigurations, or missing files.
Click to reveal answer
Which command shows live, real-time logs of a Docker container named
app?✗ Incorrect
The
-f option streams logs live. So docker logs -f app shows real-time logs.How do you limit the output to the last 20 lines of logs from a container?
✗ Incorrect
The
--tail option limits output to the last N lines.What does the
docker logs command show?✗ Incorrect
It shows the container's output and error messages for troubleshooting.
Which option adds timestamps to each log line in
docker logs?✗ Incorrect
The
--timestamps option shows when each log line was created.If a container crashes, what is the best first step to find out why?
✗ Incorrect
Checking logs helps understand the cause of the crash.
Explain how to use
docker logs to troubleshoot a container that is not working as expected.Think about how logs show what happened inside the container.
You got /5 concepts.
Describe the difference between viewing all logs and following logs live in Docker.
Compare static snapshot vs live feed.
You got /4 concepts.