The docker logs command retrieves whatever has been written to the container's STDOUT and STDERR streams that is still stored by the selected logging driver. Those records remain available after the container stops, so you can inspect failures that caused an unexpected exit. Logs are lost only when you delete the container (for example, with docker rm or by running the container with --rm). Therefore, the command can read logs from both running and stopped containers. It does not automatically follow output unless you supply the -f (follow) flag, and it does not require a specific logging driver except one that stores log records locally or forwards them elsewhere.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are Docker containers?
Open an interactive chat with Bash
What is a logging driver in Docker?
Open an interactive chat with Bash
What happens to container logs when a container stops?