如何在Docker中检查当前/默认日志记录驱动程序?

时间:2020-06-24 09:46:32

标签: docker logging driver

我正在尝试检查已停止的Docker容器的日志,但是当我执行docker logs <container-id>时,会收到如下响应:

Error response from daemon: configured logging driver does not support reading

我尝试检查默认的日志记录驱动程序,但找不到。但是,我尝试通过在/ etc / docker文件夹中创建一个daemon.json文件来与Docker中的其他驱动程序一起玩以进行日志记录。我使用service docker restart重新启动了docker服务。这也没有帮助我。这里的主要问题是I am still not able to check which driver is the system using currently and how to I get around that problem

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

很久以前问过,但我也搜索过...

您可以使用以下方法检查默认的日志记录驱动程序

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/