Possible to see stdout and stderr when a container exits?


Let’s say my Dockerfile ends with RUN ['/run.sh'] and in that script I have made a typo, and therefore the container exits right away.

Is there a way I can get to see what stdout and stderr were when it exited?

In this particular case, I don’t think Docker gets far enough for a stdout/stderr to have any content.

In general, though, you can run docker logs containername as long as the container still exists (you haven’t docker rm’d it), even if it exited.

1 Like