Errors are bound to occur once an application gets to the deployment stage. Hence, knowing how to use debugging tools and application is a critical requirement for a DevOps engineer.

This guide will show you how to debug the Docker daemon to find and resolve errors. The debugging process works by allowing the docker daemon to show the verbose output of operations happening in the background and other helpful information. In return, the logs help to identify the reason why containers or images are not working correctly.

How Docker Daemon Works

In most cases, after installing and initial setup, we do not need to worry about the docker daemon. The reason is that a system utility manages the docker daemon, thus eliminating the need for us to manage it manually. In addition, this enables the daemon to reboot automatically after restarting the host system.

How to Start Docker Daemon in Debug Mode

To debug the docker daemon, we need to start the daemon manually. Manually starting the daemon allows us to pass arguments to the dockerd command and enable the debug mode.

NOTE: Depending on your system configuration, you might need to launch the Docker daemon as root.

Enter the command below to launch docker in debug mode.

The above command dumps lots of information from the docker daemon. You can see an example output below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/1-18.png" data-lazy- height="322" src="data:image/svg xml,” width=”795″>

How to Edit Docker Configuration File

The method we illustrated above is effective when you want to start the docker daemon manually. However, if you want docker to get managed by a system utility, you will need to enable debug in the configuration file.

In Linux, you will find the docker configuration file located in /etc/docker/deamon.json. If the file does not exist, create one.

In the file, change the debug entry to true as:

{


  “registry-mirrors”: [],


  “insecure-registries”: [],


  “debug”: true,


  “experimental”: false,


  “features”: {


    “buildkit”: true


  },


  “builder”: {


    “gc”: {


      “enabled”: true,


      “defaultKeepStorage”: “20GB”


    }


  }

}

Save the file and restart the docker daemon.

$ sudo service docker restart

To read the logs, check /var/log/daemon.log in Debian-based systems. You can also use journalclt command as:

$ sudo journalctl -u docker.service.

Conclusion

In this guide, we quickly discussed how to enable and debug the docker daemon.

About the author

<img alt="" data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/john-150×150.png60dde48af0428.jpg" height="112" src="data:image/svg xml,” width=”112″>

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list