10

I'm using Papertrail to collect my Docker container's logs. Do to that, I used the syslog driver when I created the container:

sudo docker run --name my_container --log-driver=syslog  ...

... and added the following line to my /etc/rsyslog.conf

*.* @logsXXX.papertrailapp.com:YYYY

At the end, I get on Papertrail logs like this:

Apr 24 13:41:55 ip-10-1-1-86 docker/3b00635360e6: 10.0.0.5 - - [24/Apr/2015:11:41:57 +0000] "GET /healthcheck HTTP/1.1" 200 0 "-" "" "-"

The problem is that the app-name (see syslog RFC) is docker/container_id

I would rather have the container name (or host). But I don't know how to do. I tried to set a specific hostname to my container like below, but it didn't work better:

sudo docker run --name my_container -h my_container --log-driver=syslog  ...
Community
  • 1
  • 1
vcarel
  • 1,787
  • 1
  • 16
  • 23
  • 1
    Hopefully in docker v1.8 there will be a `--log-opt` option that could give you what you need. Source: http://blog.treasuredata.com/blog/2015/07/07/collecting-docker-logs-with-fluentd – Tom Jul 16 '15 at 21:18

1 Answers1

14

You can't do it. Here's a pending PR to add that feature: https://github.com/docker/docker/pull/12668

Hopefully it gets merged in soon. You could always roll your own, I suppose.

Update: Looks like this is slated for Docker 1.8

Update: This is now possible:

docker run --name my_container --log-driver=syslog --log-opt syslog-tag=my_application
Nathaniel Waisbrot
  • 23,261
  • 7
  • 71
  • 99
  • 5
    *note:* it's now "tag" and not "syslog-tag": https://docs.docker.com/engine/admin/logging/overview/#/syslog-options – Chris S Aug 24 '16 at 15:48