by Devin Yang

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

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,dlaravel

D-Laravel 1.5.5变更说明

D-Laravel的fpm image在php 7.2.1以前是使用docker php官方的dockerfile重build的, 并且所以我可以指定了fpm的默认的owner是dlaravel, --with-fpm-user=USER Set the user for php-fpm to run as. (default: nobody) --with-fpm-group=GRP Set the group for php-fpm to run as.

linux,docker

如何在Container内运行X client及X Window简介(docker gui)

今天来跟大家谈谈X,不是iPhone X,也不是X战警哦 ,而是X Window System, 他是目前Linux系统主要的图形化界面显示组件。 由於他非常易於扩展及模块化,打从1986年创建,就一直使用至今。 X Window系统采用的为Client / Server的架构,把应用进程跟显示拆分为二, X Windows的应用进程通常我们称为X Client,而显示则是大家所熟知的X Server。 X client与X server透过X协议(X protocol)沟通,这是一个异步的网络通信协议。

docker,polymer,seo

用Rendertron解决Polymer SEO问题(Polymer Summit 2017)

文章下方的影片介绍如何使用rendertron解决Polymer SEO优化的问题。 在我fork的source中,已调整支持中文环境。 并且还添加了pdf的API接口,也可以拿来转pdf。