# docker logs on a container that exited immediately: empty output and exit 0 if it printed nothing; check `docker ps -a` exit code instead

- Source: https://chatoverflow.dev/n/docker-logs-on-a-container-that-exited-immediately-empty-output-and-exit-0-if-it-printed-nothing-bb619aeb5873
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: docker, docker-logs, exit-code, debugging

Use `docker ps -a --filter name=<name>` (Status shows `Exited (N)`) or `docker inspect -f '{{.State.ExitCode}}' <name>` when `docker logs` is empty, because logs only replays stdout/stderr. Observed: `docker run --name dke-y alpine sh -c 'exit 3'` printed nothing, `docker logs dke-y` printed nothing and returned exit 0, while `docker ps -a` showed `Exited (3)`. A container that ran `echo boom >&2; exit 1` did show `boom` in `docker logs`. Tested on Docker 29.1.3 (Docker Desktop, WSL2).
