by Devin Yang

建立于: 8年前 ( 更新: 8年前 )

Docker内建相当多的日志机制,帮我们取得在container内运行的服务信息。
这些机制(mechanisms)我们通常称为logging drivers.

如果要变更默认的日志日志驱动进程(logging drivers),可在daemon.json文档设置login-driver进程的名称。这个文件通常放在linux系统的/etc/docker目录下,或在Windows则是C:\ProgramData\docker\config\
Docker默认的logging driver是json-file,把他变更为syslog。


在MacOS的系统,可以由Docker喜好设置进行设更:
daemon.json
重启后会发觉日志日志变到了syslog了。


关於更多的Docker Deamon组态设置,可以参考官方连结:
https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file

用命令来查询默认的Logging Driver.
docker info |grep Logging

下方为支持的Loggin drivers列表:
Driver Description
none No logs will be available for the container and  docker logs  will not return any output.
json-file The logs are formatted as JSON. The default logging driver for Docker.
syslog Writes logging messages to the  syslog  facility. The  syslog daemon must be running on the host machine.
journald Writes log messages to  journald . The  journald  daemon must be running on the host machine.
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
fluentd Writes log messages to  fluentd  (forward input). The  fluentd daemon must be running on the host machine.
awslogs Writes log messages to Amazon CloudWatch Logs.
splunk Writes log messages to  splunk  using the HTTP Event Collector.
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
logentries Writes log messages to Rapid7 Logentries.

我可以在用docker run命令创建container时,
或是docker-compose启动时,指定要使用的logging driver.
举例,我的Synolog Nas上的dokcer,莫明跑了一个奇怪的logging driver叫db。(下图)


我想让我的docker-compose启动时,运行json-file。
就可以补上
loggin:
  driver: json-file

 

Tags: docker

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


docker

移除所有docker containers及docker images的命令

有时在自己的环境中试了一堆container或是images,如何全部移掉系统中所有的images及container 呢?这些命令提供给大家参考..

wordpress, d-laravel, docker, docker-compose

如何用D-Laravel安装Wordpress

约8分钟的教程影片,介绍在D-Laravel上安装Wordpress. D-Laravel是一个docker-compose的Laravel框架开发环境,但不代表他不能拿来装别的东西。 这个影片,介绍使用D-Laravel安装非Laravel的PHP项目, 您可以学到D-Laravel上的相关命令用法: ./create --host用法, docker-compose up -d及 ./console mysql用法, D-Laravel v1.0.0版后的数据库连线设置方式。

php,docker,dlaravel

我创建的phpenv容器环境简单介绍

没时间拍介绍影片,我就来随便抓些画面介绍我使用的容器环境deviny/phpenv。https://github.com/DevinY/phpenvphpenv算是我之前D-Laravel开源项目的进化版本,概念上延用了很多Dlaravel的操作方式。容器的更新上偏向使用者自行控制去Build自己的image,所以我不太会去更动版号了,其实D-Laravel的php版号,好像我也很久没动啦:p