Checking Docker-Container-Logs when using Linux [Ubuntu Server 25.04]

                                            Docker Container Logs using LinuxOS







 Use Docker's logging command. The workflow is straightfoward. 


 First, identify the running container.


Run:


docker ps


 It should return the container NAME and CONTAINER ID. 


 Next, view the logs:

 

docker logs <container-name/ID-here>


That ^^^ cmd prints the full log output generated by the container.


 If the log output is large, stream it live (recommended for nodes like Kaspa):


docker logs -f <container NAME/ID here>


 This behaves like 


tail -f


and shows logs in real time.










To exit the live streams:


Ctrl + C


 That immediately returns you to the terminal prompt. The container keeps running; only the log view stops. 


to verify container is still running, 

Run:


docker ps


you should still see your container listed.


IMPORTANT DISTINCTION:


docker logs -f <container NAME/ID here>              =       Ctrl + C to exit


docker attach <container NAME/ID here>            =   Ctrl + P then Ctrl + Q


Ctrl + C is the correct move to exit the log view and exit programs in almost every case.


Additional operational flags that are useful:


Show only the most recent lines in log:


docker logs --tail 50 <container NAME/ID here> 


Include timestamps:


docker logs -t <container NAME/ID here>


Stream with timestamps:


docker logs -f -t <container NAME/ID here>    


example of entering code that i wrote with <container NAME/ID here> if kaspa-node is the container NAME/ID:


docker logs -f -t kaspa-node




 






If you forget the container name, run:


docker ps -a


that list all containers, including stopped ones, so you can target the correct log source.





Comments

Popular Posts