Docker Debugging a container Printing the logs

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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



Got any Docker Question?