How to View Docker Container Logs on Linux — Complete Guide
Use Docker's built-in logging commands to view, stream, and filter container output. Covers docker logs, live streaming, timestamps, tail, and the critical difference between logs -f and attach.
Docker Container Logs on Linux
Use Docker's built-in logging command. The workflow is straightforward.
Step 1 — Identify the Running Container
docker ps
This returns the container NAME and CONTAINER ID for all currently running containers.
Step 2 — View the Logs
docker logs <container-name-or-ID>
This prints the full log output generated by the container since it started.
Step 3 — Stream Logs Live (Recommended for Nodes)
If the log output is large, stream it in real time:
docker logs -f <container-name-or-ID>
This behaves like tail -f — it follows the log and shows new output as it appears. Especially useful for long-running processes like Kaspa nodes, Ethereum nodes, or mining bridges.
Exiting the Live Stream
Ctrl + C
This immediately returns you to the terminal prompt. The container keeps running — only the log view stops.
To verify the container is still running after exiting:
docker ps
You should still see your container listed.
⚠️ Important Distinction
| Command | Exit Method |
|---|---|
docker logs -f <name> | Ctrl + C |
docker attach <name> | Ctrl + P then Ctrl + Q |
Ctrl + C is the correct move to exit the log view in almost every case. Using Ctrl + C on
docker attachwill stop the container — not just the view. Uselogs -finstead when you just want to watch output.
“Ctrl + C is the correct move to exit the log view in almost every case. Using Ctrl + C on docker attach will stop the container — not just the view. Use logs -f instead when you just want to watch output.”
Share on XAdditional Useful Flags
Show Only the Most Recent Lines
docker logs --tail 50 <container-name-or-ID>
Include Timestamps
docker logs -t <container-name-or-ID>
Stream with Timestamps (Most Useful for Debugging)
docker logs -f -t <container-name-or-ID>
Real Example — Kaspa Node
If your container name is kaspa-node:
docker logs -f -t kaspa-node
If You Forget the Container Name
docker ps -a
This lists all containers, including stopped ones, so you can find the correct name or ID to target.
Quick Reference
| Goal | Command |
|---|---|
| List running containers | docker ps |
| View full logs | docker logs <name> |
| Stream logs live | docker logs -f <name> |
| Stream with timestamps | docker logs -f -t <name> |
| Show last N lines | docker logs --tail 50 <name> |
| List all containers (incl. stopped) | docker ps -a |
| Exit log stream | Ctrl + C |
Derrk Samuel
Web3, crypto, and Linux PC insights — practical guides, security tips, mining setups, blockchain tools, and decentralized tech strategies for techs.
Related Articles
Discussion
Leave a comment
No comments yet. Be the first to start the discussion!

