Re: [docker-compose] syslog() not work

"J.O. Aho" <[email protected]>
Newsgroups comp.lang.php
Message-ID <[email protected]>
On 24/12/2022 12.18, Custom Log wrote:
> $ 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.override.yml
> services:
>      web:
>          image: php:apache
>          extra_hosts:
>              -  "host1:192.168.1.15"
>          logging:
>              driver: syslog
>              options:
>                  syslog-address: "udp://host1:19540"
>                  tag: "{{.Name}}/{{.ID}}"
> 
> $ docker-compose run web php -r 'syslog(LOG_ERR, "ABC") && 
> print("OK!!!\n");'
> WARNING: Found orphan containers (window-resources_window-resources_1) 
> for this project. If you removed or renamed this service in your compose 
> file, you can run this command with the --remove-orphans flag to clean 
> it up.
> Creating window-resources_web_run ... done

This for you moved or deleted a composer file in another directory.

> OK!!!
> 
> $ journalctl -n | grep ABC || echo NOT FOUND
> NOT FOUND
> 
> Why?

For a socket ain't a udp or tcp port, it's a file, you need to share the 
socket file from the host into the docker image and then from within the 
docker access that socket file.

Check volumes in the docker-compose documentation.

Configure docker is generally thought as off topic as it's nothing to do 
with PHP.

-- 
  //Aho
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.