0
0
Dockerdevops~5 mins

Docker logs for troubleshooting - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Adocker logs -f app
Bdocker logs --tail 5 app
Cdocker ps app
Ddocker start app
How do you limit the output to the last 20 lines of logs from a container?
Adocker logs --tail 20 container
Bdocker logs --head 20 container
Cdocker logs --limit 20 container
Ddocker logs --last 20 container
What does the docker logs command show?
ADocker image details
BList of running containers
CDocker system info
DOutput and errors from a container
Which option adds timestamps to each log line in docker logs?
A--logtime
B--time
C--timestamps
D--date
If a container crashes, what is the best first step to find out why?
ARestart Docker service
BCheck the container logs with <code>docker logs</code>
CRemove the container
DPull the image again
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.