Capturing logs from containers
As described earlier in this chapter, containers are made of one or more processes that can fail, printing errors and describing their current state in a log file. But where are these logs stored?
Well, of course, a process in a container could write its log messages inside a file somewhere in a temporary filesystem that the container engine has made available to it (if any). But what about a read-only filesystem or any permission constraints in the running container?
A container's best practice for exposing relevant logs outside the container's shield actually leverages the use of standard streams: standard output (STDOUT
) and standard error (STDERR
).
Good to Know
Standard streams are communication channels interconnected to a running process in an OS. When a program is run through an interactive shell, these streams are then directly connected to the user's running terminal to let input, output, and error flow between the...