Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker look at the log of an exited container

Tags:

docker

Is there any way I can see the log of a container that has exited?

I can get the container id of the exited container using docker ps -a but I want to know what happened when it was running.

like image 356
Knows Not Much Avatar asked Apr 16 '16 15:04

Knows Not Much


People also ask

Can I access the logs of the docker container?

The docker logs command shows information logged by a running container. The docker service logs command shows information logged by all containers participating in a service. The information that is logged and the format of the log depends almost entirely on the container's endpoint command.


1 Answers

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 
like image 197
helmbert Avatar answered Sep 22 '22 15:09

helmbert