非常教程

Docker 17参考手册

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

记录驱动程序的日志标记(引擎) | Log tags for logging driver (Engine)

tag选项指定如何格式化标识容器日志消息的标记。默认情况下,系统使用容器id的前12个字符。若要重写此行为,请指定tag备选方案:

$ docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 --log-opt tag="mailer"

Docker支持在指定标记值时可以使用的一些特殊模板标记:

标记

描述

{{.ID}}

容器标识的前12个字符。

{{.FullID}}

完整的容器ID。

{{.Name}}

容器名称。

{{.ImageID}}

容器的图像ID的前12个字符。

{{}} .ImageFullID

容器的完整图像标识符。

{{}} .ImageName

容器使用的图像的名称。

{{.DaemonName}}

码头程序(docker)的名称。

例如,指定--log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"价值收益率syslog日志行如下:

Aug  7 18:33:19 HOSTNAME hello-world/foobar/5790672ab6a0[9103]: Hello from Docker.

启动时,系统将container_name字段和{{.Name}}在标签上。如果你用docker rename若要重命名容器,新名称不会反映在日志消息中。相反,这些消息继续使用原始容器名称。

对于高级用法,生成的标记的使用GO模板容器的日志上下文...

作为Syslog日志记录器可能实现的一个示例,如果您使用以下命令,您将得到如下输出:

$ docker run -it --rm \
    --log-driver syslog \
    --log-opt tag="{{ (.ExtraAttributes nil).SOME_ENV_VAR }}" \
    --log-opt env=SOME_ENV_VAR \
    -e SOME_ENV_VAR=logtester.1234 \
    flyinprogrammer/logtester
Apr  1 15:22:17 ip-10-27-39-73 logtester.1234[45499]: + exec app
Apr  1 15:22:17 ip-10-27-39-73 logtester.1234[45499]: 2016-04-01 15:22:17.075416751 +0000 UTC stderr msg: 1

码头工人,记录,驱动,系统日志,Fluentd,艺术,journald

引擎: 管理员指南 | 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.Graylog扩展格式(GELF)日志记录驱动程序(引擎) | Graylog Extended Format (GELF) logging driver (Engine)
12.Journald日志记录驱动程序(引擎) | Journald logging driver (Engine)
13.JSON文件日志记录驱动程序(引擎) | JSON File logging driver (Engine)
14.在守护进程停机期间保持容器处于活动状态(引擎) | Keep containers alive during daemon downtime (Engine)
15.限制容器的资源(引擎) | Limit a container's resources (Engine)
16.通过大使容器链接(引擎) | Link via an ambassador container (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