Docker look at the log of an exited container

docker logs --tail=50 <container id> for the last fifty lines - useful when your container has been running for a long time.


You can use below command to copy logs even from an exited container :

docker cp container_name:path_of_file_in_container destination_path_locally

Eg:

docker cp sample_container:/tmp/report /root/mylog

Use docker logs. It also works for stopped containers and captures the entire STDOUT and STDERR streams of the container's main process:

$ docker run -d --name test debian echo "Hello World"
02a279c37d5533ecde76976d7f9d1ca986b5e3ec03fac31a38e3dbed5ea65def

$ docker ps -a
CONTAINER ID    IMAGE     COMMAND        CREATED             STATUS                     PORTS               NAMES
49daa9d41a24    debian    "echo test"    2 minutes ago       Exited (0) 2 minutes ago                       test

$ docker logs -t test
2016-04-16T15:47:58.988748693Z Hello World

Tags:

Docker