Executando um contêiner do archlinux em um host do archlinux, ambos usando rsyslog com o mesmo arquivo de configuração:
$ cat /etc/rsyslog.conf
# Minimal config
$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog # provides kernel logging support
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$FileOwner root
$FileGroup root
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$WorkDirectory /var/spool/rsyslog
$IncludeConfig /etc/rsyslog.d/*.conf
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
mail.info -/var/log/mail.info
mail.warn -/var/log/mail.warn
mail.err /var/log/mail.err
news.crit /var/log/news/news.crit
news.err /var/log/news/news.err
news.notice -/var/log/news/news.notice
*.=debug;\
auth,authpriv.none;\
news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages
*.emerg :omusrmsg:*
Quando envio uma mensagem para o syslog no host:
$ echo hello|logger -p kern.info
$ sudo tail -1 /var/log/syslog
Jun 3 13:14:14 mothership user: hello
Mas com o mesmo comando exato no contêiner, nada é acrescentado ao / var / log / syslog (ou qualquer outro arquivo de log).
Precisões:
- rsyslog é o único syslogger instalado no host e no container
todos os serviços parecem log corretamente através do rsyslog no container
- configuração do container:
$ sudo cat /var/lib/lxc/cont/config
[sudo] password for user:
# Template used to create this container: /usr/share/lxc/templates/lxc-archlinux
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)
lxc.rootfs = /var/lib/lxc/cont/rootfs
lxc.utsname = cont
lxc.arch = i686
lxc.include = /usr/share/lxc/config/archlinux.common.conf
# tun & ttyUSB0
lxc.cgroup.devices.allow = c 10:200 rwm
lxc.cgroup.devices.allow = c 188:0 rwm
lxc.autodev = 1
lxc.pts = 1024
lxc.kmsg = 0
lxc.hook.autodev=/var/lib/lxc/cont/autodev
# network
lxc.network.type = veth
lxc.network.link = br0
lxc.network.flags = up
lxc.network.ipv4 = 10.8.10.11/24
lxc.network.ipv4.gateway = 10.8.10.10
lxc.network.name = eth0
# shares
lxc.mount.entry = /mnt/share mnt/share none bind 0 0
lxc.mount.entry = /var/cache/pacman/pkg var/cache/pacman/pkg none bind 0 0
Tags syslog lxc container rsyslog arch-linux