How to Run Docker in Verbose Mode?

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.

$ sudo docker -D

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

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.



from Linux Hint https://ift.tt/3yjnDs5

Post a Comment

0 Comments