21

I know you can check the logs of a running container with:

Command to list containers

docker container ls

Command to view the logs

docker logs [container-id]

Question:

Can you also check the logs of a failed container that is not listed, because the container failed?

Bram Janssen
  • 1,057
  • 1
  • 9
  • 14
  • Have you seen [How can I debug a docker container initialization?](https://serverfault.com/a/744711/992727)? – Zach May 02 '23 at 12:35

1 Answers1

38

Answer:

Command to list all containers, including failed / crashed containers:

docker ps -a

Now you will be able to find the id / name of your failed container and run the following command to check its logs:

docker logs [container-id]

danronmoon
  • 3,814
  • 5
  • 34
  • 56
Bram Janssen
  • 1,057
  • 1
  • 9
  • 14
  • 17
    I have a container that is crashing and it does not show up (after it crashes) in the list that I get from "docker ps -a". Is there something else I need to do? Are there logs anywhere that I can simply read without a docker command? – Jer Feb 26 '20 at 18:57
  • 6
    check for logs in /var/lib/docker/containers/ – dimisjim Sep 29 '20 at 13:57
  • 2
    @Jer you could also try to start it without `-d` flag so the container can output to stdout when the error pops up during container startup. – gies0r Mar 16 '21 at 18:01