concept container log in category docker

This is an excerpt from Manning's book Learn Docker in a Month of Lunches.
Extension fields are custom definitions; in this file there are two called
loggingandlabels. By convention you prefix the block name with an “x”, so thex-labelsblock defines an extension calledlabels. The logging extension specifies settings for container logs, and it can be used inside a service definition. The labels extension specifies a key/value pair for a label that can be used inside an existinglabelsfield in a service definition.
A Docker image is the snapshot of a filesystem with all your application binaries and dependencies, and also some metadata telling Docker which process to start when you run a container from the image. That process runs in the foreground, so it’s like starting a shell session and then running a command. As long as the command is active, it has control of the terminal input and output. Commands write log entries to the standard output and standard error streams (called stdout and stderr), so in a terminal session you see the output in your window. In a container, Docker watches stdout and stderr and collects the output from the streams--that’s the source of the container logs.