非常教程

Docker 17参考手册

引擎: 管理员指南 | Engine: Admin Guide

Graylog扩展格式(GELF)日志记录驱动程序(引擎) | Graylog Extended Format (GELF) logging driver (Engine)

gelf日志驱动程序是一种方便的格式,可以被许多工具理解,例如灰日志,,,洛格斯塔什,和流d许多工具都使用这种格式。

在GELF中,每条日志消息都是具有以下字段的块:

  • 版本
  • 主机%28谁首先发送消息?
  • 时间戳
  • 消息的简短和长篇版本
  • 配置自己的任何自定义字段

使用

使用gelf驱动程序作为默认日志记录驱动程序,设置log-driverlog-opt控件中的适当值的键。daemon.json文件,该文件位于/etc/docker/在linux主机上或C:\ProgramData\docker\config\daemon.json在WindowsServer上。有关配置Docker的更多信息,请使用daemon.json,见daemon.json...

下面的示例将日志驱动程序设置为gelf并设置gelf-address选择。

{
  "log-driver": "gelf",
  "log-opts": {
    "gelf-address": "udp://1.2.3.4:12201"
  }
}

重新启动Docker以使更改生效。

使用gelf作为新容器的默认日志记录驱动程序,传递--log-driver--log-optDocker守护进程的选项:

dockerd
  -–log-driver gelf –-log-opt gelf-address=udp://1.2.3.4:12201 \

要使配置永久化,可以在/etc/docker/daemon.json*

{
  "log-driver": "gelf",
  "log-opts":  {
    "gelf-address": "udp://1.2.3.4:12201"
  }
}

属性设置特定容器的日志驱动程序。--log-driver使用时标志docker createdocker run*

$ docker run \
      -–log-driver gelf –-log-opt gelf-address=udp://1.2.3.4:12201 \
      alpine echo hello world

GELF选项

gelf日志驱动程序支持以下选项:

Option

Description

Example value

gelf-address

The address of the GELF server. udp is the only supported URI specifier and you must specify the port.

--log-opt gelf-address=udp://192.168.0.42:12201

gelf-compression-type

The type of compression the GELF driver uses to compress each log message. Allowed values are gzip, zlib and none. The default is gzip.

--log-opt gelf-compression-type=gzip

gelf-compression-level

The level of compression when gzip or zlib is the gelf-compression-type. An integer in the range of -1 to 9 (BestCompression). Default value is 1 (BestSpeed). Higher levels provide more compression at lower speed. Either -1 or 0 disables compression.

--log-opt gelf-compression-level=2

tag

A string that is appended to the APP-NAME in the gelf message. By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the log tag option documentation for customizing the log tag format.

--log-opt tag=mailer

labels

Applies when starting the Docker daemon. A comma-separated list of logging-related labels this daemon will accept. Adds additional key on the extra fields, prefixed by an underscore (_). Used for advanced log tag options.

--log-opt labels=production_status,geo

env

Applies when starting the Docker daemon. A comma-separated list of logging-related environment variables this daemon will accept. Adds additional key on the extra fields, prefixed by an underscore (_). Used for advanced log tag options.

--log-opt env=os,customer

env-regex

Similar to and compatible with env. A regular expression to match logging-related environment variables. Used for advanced log tag options.

--log-opt env-regex=^(os | customer).

实例

此示例将容器配置为使用运行在192.168.0.42港口12201...

$ docker run -dit \
             --log-driver=gelf \
             --log-opt gelf-address=udp://192.168.0.42:12201 \
             alpine sh

灰日志,,,GELF,,,测井,,,司机

引擎: 管理员指南 | Engine: Admin Guide相关

1.Amazon CloudWatch记录日志记录驱动程序(引擎) | Amazon CloudWatch logs logging driver (Engine)
2. 绑定挂载 | Bind mounts (Engine)
3.使用Prometheus(引擎)收集Docker指标 | Collect Docker metrics with Prometheus (Engine)
4.配置和运行Docker(引擎) | Configuring and running Docker (Engine)
5.配置日志记录驱动程序 | Configuring logging drivers (Engine)
6.使用systemd控制和配置Docker(引擎) | Control and configure Docker with systemd (Engine)
7.ETW日志记录驱动程序(引擎) | ETW logging driver (Engine)
8.流利的日志驱动程序(引擎) | Fluentd logging driver (Engine)
9.格式化命令和日志输出(引擎) | Format command and log output (Engine)
10.Google Cloud日志记录驱动程序(引擎) | Google Cloud logging driver (Engine)
11.Journald日志记录驱动程序(引擎) | Journald logging driver (Engine)
12.JSON文件日志记录驱动程序(引擎) | JSON File logging driver (Engine)
13.在守护进程停机期间保持容器处于活动状态(引擎) | Keep containers alive during daemon downtime (Engine)
14.限制容器的资源(引擎) | Limit a container's resources (Engine)
15.通过大使容器链接(引擎) | Link via an ambassador container (Engine)
16.记录驱动程序的日志标记(引擎) | Log tags for logging driver (Engine)
17.Logentries日志驱动程序(引擎) | Logentries logging driver (Engine)
18.PowerShell DSC用法(引擎) | PowerShell DSC usage (Engine)
19.修剪未使用的Docker对象(引擎) | Prune unused Docker objects (Engine)
20.在容器中运行多个服务(引擎) | Run multiple services in a container (Engine)
21.运行时指标(引擎) | Runtime metrics (Engine)
22.Splunk日志记录驱动程序(引擎) | Splunk logging driver (Engine)
23.自动启动容器(引擎) | Start containers automatically (Engine)
24.存储概述(引擎) | Storage overview (Engine)
25.Syslog日志记录驱动程序(引擎) | Syslog logging driver (Engine)
26.tmpfs mounts
27.解决卷问题(引擎) | Troubleshoot volume problems (Engine)
28.使用日志驱动程序插件(引擎) | Use a logging driver plugin (Engine)
29.使用Ansible(引擎) | Using Ansible (Engine)
30.使用Chef(引擎) | Using Chef (Engine)
31.使用Puppet(引擎) | Using Puppet (Engine)
32.查看容器的日志(引擎) | View a container's logs (Engine)
33.Volumes (Engine)
Docker 17

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

主页 https://docker.com/
源码 https://github.com/docker/docker
版本 17
发布版本 17.06