简体   繁体   中英

How to forward logs from docker containers to host journald/syslog service?

I want to send all logs from docker postgresql container to my host journald service.

ie I want to be able to read docker container logs at host machine using tail -f /var/logs/messages or journald -f

here is my docker-compose config:

  postgres:
    restart: unless-stopped
    image: postgres:9.6
    ports:
      - "5432:5432"
    logging:
      driver: syslog
      options:
        syslog-address: "udp://127.0.0.1:514"

I've been trying different solutions but everytime i got an error from docker:

postgres_1  | WARNING: no logs are available with the 'syslog' log driver

and I cannot get see logs on the host machine.

I'm not sure, what I'm doing wrong?

Thank you in advance

For now, docker-compose does not support any logs driver except json-file and journald https://github.com/docker/compose/blob/master/compose/container.py#L173

But journald still does not post anything to host machine it just prints everything to the screen withoud -d options. I think that's build in behavior you cannot change

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM