Docker Printing the logs


Example

Following the logs is the less intrusive way to debug a live running application. This example reproduces the behavior of the traditional tail -f some-application.log on container 7786807d8084.

docker logs --follow --tail 10 7786807d8084

This command basically shows the standard output of the container process (the process with pid 1).

If your logs do not natively include timestamping, you may add the --timestamps flag.

It is possible to look at the logs of a stopped container, either

  • start the failing container with docker run ... ; docker logs $(docker ps -lq)

  • find the container id or name with

docker ps -a

and then

docker logs container-id or

docker logs containername

as it is possible to look at the logs of a stopped container