我将Docker容器设置为将日志发送到CentOS 7上的主机日志(使用–log-driver syslog).我想在macOS(Sierra)上复制这个.但它似乎没有出现在任何地方.
$docker run --log-driver syslog -it busybox sh
/ # logger "Hello world!"
/ # exit
和:
$sudo cat /var/log/system.log | grep "Hello world"
Password:
$
什么配置是必要的,以使任何容器的任何Docker系统日志记录命令都可以出现在macOS上的日志文件中?
如果我不配置日志驱动程序,我可以查看这些类型的默认系统日志记录.但Ruby的syslog实现必须以不同方式记录.
$docker run --log-driver syslog -it centos /bin/bash
# yum install ruby -y
# ruby -e "require 'syslog/logger'; log = Syslog::Logger.new 'my_program'; log.info 'this line will be logged via syslog(3)'"
# exit
$sudo tail -n 10000 /var/log/system.log | grep "syslog(3)"
$
如Daniel Walsh“Better ways of handling logging in containers ”所述:
One big problem with standard docker containers is that any service that writes messages to syslog or directly to the journal get dropped by default.
Docker does not record any logs unless the messages are written to STDIN/STDERR. There is no logging service running inside of the container to catch these messages.
所以一个简单的echo最终应该在syslog中,如chentex/random-logger
图像所示.
从Docker for Mac / Log and Troubleshooting开始,您可以在docker运行后直接查看是否有任何日志:
To view Docker for Mac logs at the command line,type this command in a terminal window or your favorite shell.
$syslog -k Sender Docker
检查〜/ Library / Containers / com.docker.docker / Data / com.docker.driver.amd64-linux / log的内容.
系统日志驱动程序已于PR 11458添加
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。