How to check the current/default logging driver in docker?
Asked Answered
R

2

7

I am trying to check the logs of a stopped docker container, but when I do docker logs <container-id> I get a response as follows:

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

I tried checking for the default logging driver but I could not find out. However, I tried playing with some other drivers in docker for logging by creating a daemon.json file in the /etc/docker folder. I restarted the docker service using service docker restart. This did not help me either. The main problem here is I am still not able to check which driver is the system using currently and how to I get around that problem?

Can someone please help me with this?

Reyreyes answered 24/6, 2020 at 9:46 Comment(0)
B
12

Asked long ago, but I've also searched for that...

You can check the default logging driver with

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

Alternatively,

ars@ars-thinkpad ~ $ docker info --format '{{.LoggingDriver}}'
json-file

To get the driver of the existing container,

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": {

So it is json-file with the actual log file path /var/lib/docker/containers/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df/a48314f1c16356f3cf534b273ea3871a26882d1466979c48e38611d8106594df-json.log in my case.

See also https://docs.docker.com/config/containers/logging/configure/

Bismuthinite answered 11/9, 2020 at 8:26 Comment(0)
M
-1

First, get the container id of your pod using:

kubectl get pod <pod-name> -n <namespace> -o jsonpath='{.status.containerStatuses[*].containerID}'

Now, run below command to get the default logging driver:

sudo docker inspect -f '{{.HostConfig.LogConfig.Type}}' <container-id>
Major answered 7/7, 2023 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.