tech687
(Tech687)
December 23, 2022, 4:10pm
1
$ cat docker-compose.yml
services:
web:
image: php:apache
logging:
driver: syslog
# options:
# syslog-address: "udp://XXX.papertrailapp.com:XXXX"
# tag: "{{.Name}}/{{.ID}}"
$ docker-compose run web systemctl status syslogg
Creating network "tmpldrctauwpb_default" with the default driver
Creating tmpldrctauwpb_web_run ... done
/usr/local/bin/docker-php-entrypoint: 9: exec: systemctl: not found
ERROR: 127
$ docker-compose run web journalctl
Creating tmpldrctauwpb_web_run ... done
/usr/local/bin/docker-php-entrypoint: 9: exec: journalctl: not found
ERROR: 127
Why?
meyay
(Metin Y.)
December 23, 2022, 4:50pm
2
If you specify the syslog for your service, then the container`s STDOUT and STDERR are send to the hosts syslog. This happens on the host level, not from inside the container.
I am not sure why expect systemd and its tools to be existing inside the container for that…
tech687
(Tech687)
December 23, 2022, 8:20pm
3
$ sudo ls -la /proc/$(pidof rsyslogd)/fd
totale 0
dr-x------ 2 root root 0 dic 23 08:54 .
dr-xr-xr-x 9 syslog syslog 0 dic 23 08:54 ..
lr-x------ 1 root root 64 dic 23 20:54 0 -> /dev/null
l-wx------ 1 root root 64 dic 23 20:54 1 -> /dev/null
l-wx------ 1 root root 64 dic 23 20:54 2 -> /dev/null
lrwx------ 1 root root 64 dic 23 08:54 3 -> 'socket:[19540]'
lr-x------ 1 root root 64 dic 23 20:54 4 -> /dev/urandom
lr-x------ 1 root root 64 dic 23 20:54 5 -> /proc/kmsg
lrwx------ 1 root root 64 dic 23 20:54 6 -> 'socket:[29286]'
l-wx------ 1 root root 64 dic 23 20:54 7 -> /var/log/syslog
l-wx------ 1 root root 64 dic 23 20:54 8 -> /var/log/kern.log
l-wx------ 1 root root 64 dic 23 20:54 9 -> /var/log/auth.log
$ netstat -x | grep 19540
unix 2 [ ] DGRAM 19540 /run/systemd/journal/syslog
$ cat docker-compose.yml
services:
web:
image: php:apache
ports:
- 8003:80
volumes:
- .:/var/www/html
logging:
driver: syslog
options:
syslog-address: "udp://localhost:19540"
# tag: "{{.Name}}/{{.ID}}"
$ cat index.php
<?php
var_dump(syslog(LOG_ERR, 'ABC'));
$ docker-compose up -d && curl http://localhost:8003
syslog_web_1 is up-to-date
bool(true)
$ journalctl -n | grep ABC
NO OUTPUT