Standard error, or stderr, is a process output stream conventionally used for diagnostic and error messages. Docker watches stderr alongside standard output and collects both streams as container logs, whether the process runs attached or detached. section 19.1
In a container workflow:
- A foreground process writes output to stderr or stdout, which appears in the terminal. section 19.1
- Docker collects stderr and stdout as container logs. section 19.1
- Docker stores collected entries as JSON records identifying the originating stream and timestamp. section 19.1
Inspect container output
Run a detached container with `docker run -d --name timecheck diamol/ch19-timecheck:2e`, then retrieve its latest collected output with `docker logs --tail 1 timecheck`. The command works after stopping the container because Docker retains the collected logs. section 19.1
# run a detached container:
docker run -d --name timecheck diamol/ch19-timecheck:2e
# check the most recent log entry:
docker logs --tail 1 timecheck
# stop the container and check the logs again:
docker stop timecheck
docker logs --tail 1 timecheck
# check where Docker stores the container log file:
docker container inspect --format='{{.LogPath}}' timecheck
Use the command listing to compare detached execution, log retrieval, stopping, and inspection of Docker's log-file path. section 19.1

