适用于 Docker 的弹性日志记录插件:"error creating logger" , "hosts flag is required"



在Ubuntu 22.04上运行Docker 20.10.22 .

我正在尝试配置我的Docker容器来登录到Elastic Cloud,要么默认通过/etc/docker/daemon.json的机制,要么通过使用命令行标志。

我已经尝试了一个守护进程文件,像这样:

me@server:~$ cat /etc/docker/daemon.json
{
"log-driver": "elastic/elastic-logging-plugin:8.5.3",
"log-opts": {
"cloud_id": "...",
"api_key": "...",
"output.elasticsearch.index": "dockerlogs-wiki-%{+yyyy.ww}",
"max-file": "10",
"max-size": "4M"
}
}

Elastic Logging插件可用并已启用:

me@server:~$ docker plugin ls
ID             NAME                                   DESCRIPTION              ENABLED
54832cf3f8f6   elastic/elastic-logging-plugin:8.5.3   A beat for docker logs   true

重新启动Docker与sudo systemctl restart docker加载daemon.json后,我得到这个:

me@server:~$ docker create --name=container-name -v /var/run/docker.sock:/var/run/docker.sock:ro --restart=unless-stopped -h container-name --network=mynetwork ghcr.io/org/container-name:latest
09e3001a8a5507be2aa0cca44d3e9735dd7a6f4c3c59bb9f5a35c941f74fe240
me@server:~$ docker start container-name
Error response from daemon: failed to initialize logging driver: error creating logger: LogDriver.StartLogging: error creating client config: A hosts flag is required
Error: failed to start containers: container-name

我也试过没有守护进程文件,只有CLI标志:

me@server:~$ docker create --name=container-name 
-v /var/run/docker.sock:/var/run/docker.sock:ro 
--restart=unless-stopped 
-h container-name 
--network=wikinet 
--log-driver=elastic/elastic-logging-plugin:8.5.3 
--log-opt cloud_id="..." 
--log-opt api_key="..." 
--log-opt max-file=10 
--log-opt max-size=5M 
ghcr.io/org/container-name:latest
09e3001a8a5507be2aa0cca44d3e9735dd7a6f4c3c59bb9f5a35c941f74fe240
me@server:~$ docker start container-name
Error response from daemon: failed to initialize logging driver: error creating logger: LogDriver.StartLogging: error creating client config: A hosts flag is required
Error: failed to start containers: container-name

相同的结果。如果有任何关于如何调试的想法,我将非常欢迎。

指定--log-opt hosts=""使错误消失,日志出现在Elastic Cloud中。应该没有必要,但我们在这里。

相关内容

  • 没有找到相关文章

最新更新