liveBook · Manning

Standard error

As explained in Learn Docker in a Month of Lunches, Second Edition

Standard error is the conventional process stream for diagnostic and error output.

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

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains process streams, foreground behavior, Docker collection, JSON records, and retained log files without detailing application-level error handling.
Examples
Demonstrates a foreground time-printing container, detached execution, docker logs, retained output, and JSON stream records.
What it assumes
Assumes basic process and terminal behavior while establishing how foreground applications and containers expose output streams.
What you can do after
Operate Docker logging by running containers, retrieving stderr-inclusive logs, and inspecting retained log storage.
How it connects
Connects standard error with standard output, foreground processes, Docker containers, and container logs.

Also explained in

Compare how 2 books explain standard error →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.