我想隔离docker中的测试环境,我在CentOS 6 How to let syslog workable in docker?
上做到了在CentOS 7中,运行时syslog-ng的配置不同
/usr/sbin/syslog-ng -F -p /var/run/syslogd.pid
出现以下错误消息,但配置文件中没有proc / kmsg。
syslog-ng: Error setting capabilities, capability management disabled; error='Operation not permitted'
Error opening file for reading; filename='/proc/kmsg', error='Operation not permitted (1)'
Dockerfile
FROM centos
RUN yum update --exclude=systemd -y \
&& yum install -y yum-plugin-ovl \
&& yum install -y epel-release
RUN yum install -y syslog-ng syslog-ng-libdbi
测试过程:
docker build -t t1 .
docker run --rm -i -t t1 /bin/bash
在容器中,运行以下命令
# check config, no keyword like proc/kmsg
cd /etc/syslog-ng
grep -r -E 'proc|kmsg'
/usr/sbin/syslog-ng -F -p /var/run/syslogd.pid
答案 0 :(得分:2)
从更改/etc/syslog-ng/syslog-ng.conf
source s_sys {
system();
internal();
};
到
source s_sys {
unix-stream("/dev/log");
internal();
};
它仍然显示错误消息,但是运行而不是退出
syslog-ng: Error setting capabilities, capability management disabled; error='Operation not permitted'
要解决此问题,只需运行--no-caps
选项
/usr/sbin/syslog-ng --no-caps -F -p /var/run/syslogd.pid