Recall & Review
beginner
What command shows the logs of a running Docker container?
Use
docker logs <container_name_or_id> to see the output and messages from a running container.Click to reveal answer
beginner
How do you follow the logs in real-time for a Docker container?
Add the
-f or --follow option: docker logs -f <container_name_or_id> to watch new log entries as they appear.Click to reveal answer
intermediate
How can you limit the number of log lines shown from a Docker container?
Use the
--tail <number> option, for example: docker logs --tail 10 <container_name_or_id> shows only the last 10 lines.Click to reveal answer
beginner
What does the
docker logs command show by default?It shows all the logs that the container has produced since it started, including standard output and standard error.
Click to reveal answer
intermediate
Can you view logs of a stopped Docker container?
Yes,
docker logs works for stopped containers too, showing the logs they produced before stopping.Click to reveal answer
Which command shows the logs of a Docker container named 'webapp'?
✗ Incorrect
The correct command is
docker logs webapp to view logs.How do you watch logs live as they are generated?
✗ Incorrect
Use
docker logs -f <container> to follow logs live.What option limits the number of log lines shown?
✗ Incorrect
The
--tail option limits log lines shown.Can you view logs of a container that is not running?
✗ Incorrect
Docker saves logs and you can view them even after the container stops.
What does the
docker logs command show by default?✗ Incorrect
By default, it shows all logs since the container started.
Explain how to view and follow logs of a Docker container in real-time.
Think about how you watch a live video feed of logs.
You got /4 concepts.
Describe how to limit the number of log lines shown when viewing Docker container logs.
Imagine you only want to see the last few messages, not everything.
You got /4 concepts.