Docker CE 和系统日志

Docker CE and syslog

Docker日志驱动是网上指定的,还有这些限制。

Limitations of logging drivers

Users of Docker Enterprise can make use of “dual logging”, which enables you to use the docker logs command for any logging driver. Refer to reading logs when using remote logging drivers for information about using docker logs to read container logs locally for many third party logging solutions, including:

syslog

gelf

fluentd

awslogs

splunk

etwlogs

gcplogs

Logentries

When using Docker Community Engine, the docker logs command is only available on the following drivers:

local

json-file

journald

Reading log information requires decompressing rotated log files, which causes a temporary increase in disk usage (until the log entries from the rotated files are read) and an increased CPU usage while decompressing.

The capacity of the host storage where the Docker data directory resides determines the maximum size of the log file information.

我正在使用 Docker CE,但我对此文档有疑问。这是否意味着,使用 CE,我根本无法执行系统日志?或者只是我不能做系统日志并且有 docker 日志?

没有什么可以阻止您在容器内使用系统日志,但您无法使用 'docker logs' 命令读取这些日志。也没有什么可以阻止您将日志写入 stdout 并将日志通过管道传输到您想要的任意数量的日志传送器。

这里有一篇文章解释了如何在 docker 容器中执行系统日志:https://medium.com/better-programming/docker-centralized-logging-with-syslog-97b9c147bd30

我认为 fluentd 和 fluent-bit 现在是比 syslog 更好的选择,因为它们提供给 msg 字段的结构,尽管 syslog-ng 看起来很有趣。 Fluent-bit 非常好,所以你可能想看一看。