Local file logging driver
local logging driver captures output from container's stdout/stderr and
writes them to an internal storage that's optimized for performance and disk
By default, the
local driver preserves 100MB of log messages per container and
uses automatic compression to reduce the size on disk. The 100MB default value is based on a 20M default size
for each file and a default count of 5 for the number of such files (to account for log rotation).
locallogging driver uses file-based storage. These files are designed to be exclusively accessed by the Docker daemon. Interacting with these files with external tools may interfere with Docker's logging system and result in unexpected behavior, and should be avoided.
To use the
local driver as the default logging driver, set the
log-opt keys to appropriate values in the
daemon.json file, which is
/etc/docker/ on Linux hosts or
C:\ProgramData\docker\config\daemon.json on Windows Server. For more about
configuring Docker using
The following example sets the log driver to
local and sets the
Restart Docker for the changes to take effect for newly created containers. Existing containers don't use the new logging configuration automatically.
You can set the logging driver for a specific container by using the
--log-driver flag to
docker container create or
$ docker run \
--log-driver local --log-opt max-size=10m \
alpine echo hello world
local is a bash reserved keyword, so you may need to quote it in scripts.
local logging driver supports the following logging options:
|The maximum size of the log before it's rolled. A positive integer plus a modifier representing the unit of measure (
g). Defaults to 20m.
|The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer. Defaults to 5.
|Toggle compression of rotated log files. Enabled by default.
This example starts an
alpine container which can have a maximum of 3 log
files no larger than 10 megabytes each.
$ docker run -it --log-driver local --log-opt max-size=10m --log-opt max-file=3 alpine ash