Enabling Debug mode in Docker

In order to troubleshoot Docker issues effectively, we can enable the debug mode in docker to get more information.

Before enabling Debug mode,

# docker info

[root@cent7-node-1 ~]# docker info | grep -i debug
Debug Mode (client): false
Debug Mode (server): false
[root@cent7-node-1 ~]#

# journalctl -u docker.service

[root@cent7-node-1 ~]# journalctl -u docker.service | tail
Aug 12 11:38:12 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:12-04:00" level=info msg="containerd successfully booted in 0.056393s" module=containerd
Aug 12 11:38:12 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:12.234598490-04:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Aug 12 11:38:12 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:12.329094260-04:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Aug 12 11:38:12 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:12.330976384-04:00" level=info msg="Loading containers: start."
Aug 12 11:38:13 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:13.177967551-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Aug 12 11:38:13 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:13.370679508-04:00" level=info msg="Loading containers: done."
Aug 12 11:38:13 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:13.602407956-04:00" level=info msg="Docker daemon" commit=9ee9f40 graphdriver(s)=overlay2 version=18.03.1-ce
Aug 12 11:38:13 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:13.618898485-04:00" level=info msg="Daemon has completed initialization"
Aug 12 11:38:13 cent7-node-1 dockerd[984]: time="2018-08-12T11:38:13.649157141-04:00" level=info msg="API listen on /var/run/docker.sock"
Aug 12 11:38:13 cent7-node-1 systemd[1]: Started Docker Application Container Engine.
[root@cent7-node-1 ~]#

We can enable the Debug mode by editing any one of the below file,

1) Editing ‘/etc/sysconfig/docker’

or

2) Editing ‘/etc/docker/daemon.json’

1) changes via ‘/etc/sysconfig/docker’

Add the below content in the above file,

OPTIONS=’–selinux-enabled -l debug’

or

OPTIONS=’–selinux-enabled -D’

[root@cent7-node-1 ~]# cat /etc/sysconfig/docker
OPTIONS='--selinux-enabled -l debug'
[root@cent7-node-1 ~]#

2) Changes via ‘/etc/docker/daemon.json’

Update the file content as below,

[root@cent7-node-1 ~]# cat /etc/docker/daemon.json
{
"debug": true
}
[root@cent7-node-1 ~]#

After making changes in any one of the file, restart the Docker service as below,

#systemctl restart docker

[root@cent7-node-1 ~]# systemctl restart docker
[root@cent7-node-1 ~]# systemctl status docker
‚óŹ docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2018-08-12 12:00:50 EDT; 2s ago
Docs: https://docs.docker.com
Main PID: 1650 (dockerd)

[root@cent7-node-1 ~]# docker info | grep -i debug
Debug Mode (client): false
Debug Mode (server): true
[root@cent7-node-1 ~]#

[root@cent7-node-1 ~]# journalctl -u docker.service | tail
Aug 12 12:00:50 cent7-node-1 dockerd[1650]: time="2018-08-12T12:00:50.681328621-04:00" level=debug msg="Registering POST, /networks/create"
Aug 12 12:00:50 cent7-node-1 dockerd[1650]: time="2018-08-12T12:00:50.681373067-04:00" level=debug msg="Registering POST, /networks/{id:.*}/connect"
Aug 12 12:00:50 cent7-node-1 dockerd[1650]: time="2018-08-12T12:00:50.681433332-04:00" level=debug msg="Registering POST, /networks/{id:.*}/disconnect"
Aug 12 12:00:50 cent7-node-1 dockerd[1650]: time="2018-08-12T12:00:50.681484356-04:00" level=debug msg="Registering POST, /networks/prune"
Aug 12 12:00:50 cent7-node-1 dockerd[1650]: time="2018-08-12T12:00:50.681532213-04:00" level=debug msg="Registering DELETE, /networks/{id:.*}"
Aug 12 12:00:50 cent7-node-1 dockerd[1650]: time="2018-08-12T12:00:50.682210128-04:00" level=info msg="API listen on /var/run/docker.sock"
Aug 12 12:01:03 cent7-node-1 dockerd[1650]: time="2018-08-12T12:01:03.169426558-04:00" level=debug msg="Calling GET /_ping"
Aug 12 12:01:03 cent7-node-1 dockerd[1650]: time="2018-08-12T12:01:03.170993544-04:00" level=debug msg="Calling GET /v1.37/info"
Aug 12 12:01:40 cent7-node-1 dockerd[1650]: time="2018-08-12T12:01:40.390612870-04:00" level=debug msg="Calling GET /_ping"
Aug 12 12:01:40 cent7-node-1 dockerd[1650]: time="2018-08-12T12:01:40.391363717-04:00" level=debug msg="Calling GET /v1.37/containers/json"
[root@cent7-node-1 ~]#

Hence, we have enabled the debug mode in Docker

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: