docker 守护进程忽略了日志标签选项
log tag option ignored by docker daemon
我在 Ubuntu 16.04 有一个 docker.conf 的 system.d,看起来像这样:
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H tcp://127.0.0.1:2376 --log-driver syslog --log-opt tag='docker/{{.Name}}'
我希望 var/log/syslog 中的标签看起来像 docker/ 但它仍在使用 {{.Name}}/{{.ID}}
我还需要更改什么吗?
从文档中看不太清楚,但是容器的日志标记配置是在构建容器时生成的。
如果您重建容器,那么您应该会看到用新标签标记的日志记录。
我 Docker version 17.05.0-ce, build 89658be
就是这种情况。
引导我进行此发现的线索来自 https://docs.docker.com/engine/admin/logging/log_tags/:
If you use docker rename to rename a container,
the new name is not reflected in the log messages. Instead, these
messages continue to use the original container name.
但是,如果您使用的是 docker-compose,那么在日志选项下设置标签选项会在容器重新启动时生效:
例如
services:
nginx:
logging:
options:
tag: "docker/{{.Name}}"
我在 Ubuntu 16.04 有一个 docker.conf 的 system.d,看起来像这样:
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H tcp://127.0.0.1:2376 --log-driver syslog --log-opt tag='docker/{{.Name}}'
我希望 var/log/syslog 中的标签看起来像 docker/ 但它仍在使用 {{.Name}}/{{.ID}}
我还需要更改什么吗?
从文档中看不太清楚,但是容器的日志标记配置是在构建容器时生成的。
如果您重建容器,那么您应该会看到用新标签标记的日志记录。
我 Docker version 17.05.0-ce, build 89658be
就是这种情况。
引导我进行此发现的线索来自 https://docs.docker.com/engine/admin/logging/log_tags/:
If you use docker rename to rename a container, the new name is not reflected in the log messages. Instead, these messages continue to use the original container name.
但是,如果您使用的是 docker-compose,那么在日志选项下设置标签选项会在容器重新启动时生效:
例如
services:
nginx:
logging:
options:
tag: "docker/{{.Name}}"