Docker 与 syslog 驱动程序,重复但被截断/乱码的行

Docker 与 syslog 驱动程序,重复但被截断/乱码的行

我正在尝试让我的 docker 容器写入 syslog,作为管理单个盒子上少量容器日志记录的第一步。

配置如下所示:

cat /etc/docker/daemon.json

{
  "log-driver": "syslog",
  "log-opts": {
    "tag": "docker"
  }
}

cat /etc/rsyslog.d/10-dockerd.conf

# Log docker generated log messages to file
:programname, isequal, "docker" /var/log/docker
& stop

但是,这会导致日志中出现重复/半截断的行(仅运行图像hello-world,但也发生在我自己的图像上:

cat /var/log/docker

Jun  4 13:47:03 hostname_here_ docker[12146]:
Jun  4 13:47:03 hostname_here_ docker[12146]: Hello from Docker!
Jun  4 13:47:03 hostname_here_ docker[12146]: This message shows that your installation appears to be working correctly.
Jun  4 13:47:03 hostname_here_ docker[12146]: correctly.
Jun  4 13:47:03 hostname_here_ docker[12146]: To generate this message, Docker took the following steps:
Jun  4 13:47:03 hostname_here_ docker[12146]: 1. The Docker client contacted the Docker daemon.
Jun  4 13:47:03 hostname_here_ docker[12146]: 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
Jun  4 13:47:03 hostname_here_ docker[12146]:    (amd64)
Jun  4 13:47:03 hostname_here_ docker[12146]: 3. The Docker daemon created a new container from that image which runs the
Jun  4 13:47:03 hostname_here_ docker[12146]:    executable that produces the output you are currently reading.
Jun  4 13:47:03 hostname_here_ docker[12146]: 4. The Docker daemon streamed that output to the Docker client, which sent it
Jun  4 13:47:03 hostname_here_ docker[12146]:    to your terminal.
Jun  4 13:47:03 hostname_here_ docker[12146]: inal.
Jun  4 13:47:03 hostname_here_ docker[12146]: To try something more ambitious, you can run an Ubuntu container with:
Jun  4 13:47:03 hostname_here_ docker[12146]: $ docker run -it ubuntu bash
Jun  4 13:47:03 hostname_here_ docker[12146]: t ubuntu bash
Jun  4 13:47:03 hostname_here_ docker[12146]: Share images, automate workflows, and more with a free Docker ID:
Jun  4 13:47:03 hostname_here_ docker[12146]: https://hub.docker.com/
Jun  4 13:47:03 hostname_here_ docker[12146]: ker.com/
Jun  4 13:47:03 hostname_here_ docker[12146]: For more examples and ideas, visit:
Jun  4 13:47:03 hostname_here_ docker[12146]: https://docs.docker.com/get-started/
Jun  4 13:47:03 hostname_here_ docker[12146]: rted/

例如

Jun  4 13:47:03 hostname_here_ docker[12146]: This message shows that your installation appears to be working correctly.
Jun  4 13:47:03 hostname_here_ docker[12146]: correctly.
...
Jun  4 13:47:03 hostname_here_ docker[12146]:    to your terminal.
Jun  4 13:47:03 hostname_here_ docker[12146]: inal.
...
Jun  4 13:47:03 hostname_here_ docker[12146]: $ docker run -it ubuntu bash
Jun  4 13:47:03 hostname_here_ docker[12146]: t ubuntu bash

似乎与行长无关。这是 AWS 中的 RHEL7.6 映像。其他配置(docker/rsyslog)为默认。

有谁经历过类似的事情吗?

相关内容