docker - 如何检查 docker 中的当前/默认日志驱动程序?
问题描述
我正在尝试检查已停止的 docker 容器的日志,但是当我这样做时,docker logs <container-id>
我得到如下响应:
Error response from daemon: configured logging driver does not support reading
我尝试检查默认的日志记录驱动程序,但我找不到。daemon.json
但是,我尝试通过在 /etc/docker 文件夹中创建一个文件来使用 docker 中的其他一些驱动程序进行日志记录。我使用 重新启动了 docker 服务service docker restart
。这也没有帮助我。这里的主要问题是I am still not able to check which driver is the system using currently and how to I get around that problem
?
有人可以帮我吗?
解决方案
很久以前问过,但我也搜索过......
您可以检查默认的日志记录驱动程序
ars@ars-thinkpad ~ $ docker system info | grep -i log
Logging Driver: json-file
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
WARNING: No swap limit support
或者,
ars@ars-thinkpad ~ $ docker info --format '{{.LoggingDriver}}'
json-file
要获取现有容器的驱动程序,
ars@ars-thinkpad ~ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a48314f1c163 tests_node3 "/pg/mmts/tests/dock…" 10 minutes ago Up 10 minutes 0.0.0.0:15434->5432/tcp node3
ars@ars-thinkpad ~ $ docker inspect a48314f1c163 | grep -i -C 5 log
},
"Image": "sha256:80493e979e72a027d07ef5db2c7486d1913ff4ae224eb8a5b93a93320f51844d",
"ResolvConfPath": "/var/lib/docker/containers/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df/hostname",
"HostsPath": "/var/lib/docker/containers/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df/hosts",
"LogPath": "/var/lib/docker/containers/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df-json.log",
"Name": "/node3",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
--
"AppArmorProfile": "unconfined",
"ExecIDs": null,
"HostConfig": {
"Binds": [],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "tests_mtm_bridge",
"PortBindings": {
因此,在我的情况下,它json-file
与实际的日志文件路径有关。/var/lib/docker/containers/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df-json.log
另请参阅 https://docs.docker.com/config/containers/logging/configure/
推荐阅读
- oracle - 检查记录是否是该月的第一个
- elm - 榆树记录速记符号
- regex - N 位的正则表达式总是以 2 开头
- python - 类中调用的 pygame.draw.rect() 函数不显示矩形
- php - 为什么“exit()”之后代码还在执行?
- php - 单击退出按钮时在退出操作之前显示模式表单
- ruby-on-rails - Json 在嵌套查询轨道上看起来不漂亮
- r - 如何改变二分图中第一类和第二类顶点的类型?
- javascript - CSS Animations are not smooth on Chrome (iOS)
- java - How to get any numbers sorted from string variable in Java?