> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Docker Debug Mode

> Learn to enable Docker debug mode, verify its status, and inspect detailed logs during container operations.

In this demo, you’ll learn how to turn on Docker daemon debug mode, verify that it’s active, and inspect verbose logs during container operations.

## 1. Check Current Debug Status

Start by viewing your Docker daemon’s current settings:

```bash theme={null}
docker system info
```

Look for the `Debug Mode` line in the output:

```text theme={null}
Debug Mode: false
```

## 2. Create a Test Container & Inspect Default Logs

Launch a simple HTTPD container:

```bash theme={null}
docker run -d --name test httpd:latest
```

Then review your system log (e.g., `/var/log/messages` or `journalctl -u docker.service`). You should only see high-level entries about container creation:

```bash theme={null}
tail -n 20 /var/log/messages
```

## 3. Enable Docker Debug Mode

To capture detailed debug output, edit the Docker daemon configuration:

1. Open `/etc/docker/daemon.json` (create it if missing) and add:

   ```json theme={null}
   {
     "debug": true
   }
   ```

<Callout icon="lightbulb" color="#1CB2FE">
  If the file doesn’t exist, you can create it. Make sure the JSON remains valid—use a JSON linter if needed.
</Callout>

2. Reload the Docker daemon:

```bash theme={null}
sudo systemctl reload docker
```

## 4. Confirm Debug Mode Is Active

Run the inspect command again:

```bash theme={null}
docker system info
```

Now you should see `Debug Mode: true` along with extra metrics:

```text theme={null}
Debug Mode: true
File Descriptors: 23
Goroutines: 36
System Time: 2020-05-21T11:38:33.79317432Z
EventsListeners: 0
```

## 5. Generate and View Verbose Logs

Create a new container called `test_debug`:

```bash theme={null}
docker run -d --name test_debug httpd:latest
```

Then tail your logs to see debug-level details:

```bash theme={null}
tail -n 20 /var/log/messages
```

You’ll notice granular messages describing each step of the container lifecycle.

## 6. Reload Docker with SIGHUP & Disable Debug

If you prefer a manual reload instead of `systemctl`:

1. Update `/etc/docker/daemon.json` to disable debug mode:

   ```json theme={null}
   {
     "debug": false
   }
   ```

2. Identify the Docker daemon PID and send `SIGHUP`:

   ```bash theme={null}
   pid=$(pgrep dockerd)
   sudo kill -SIGHUP $pid
   ```

<Callout icon="triangle-alert" color="#FF6B6B">
  Always verify you have the correct PID before sending signals. Killing the wrong process can disrupt your system.
</Callout>

3. Check that debug is now off:

```bash theme={null}
docker system info | grep "Debug Mode"
```

***

## Command Reference

| Action                       | Command                                              |                     |
| ---------------------------- | ---------------------------------------------------- | ------------------- |
| Check debug status           | `docker system info`                                 |                     |
| Launch a container           | `docker run -d --name <name> httpd:latest`           |                     |
| View system logs             | `tail -n 20 /var/log/messages`                       |                     |
| Enable debug in daemon.json  | Add `"debug": true` to `/etc/docker/daemon.json`     |                     |
| Reload Docker via systemd    | `sudo systemctl reload docker`                       |                     |
| Reload Docker via SIGHUP     | `sudo kill -SIGHUP $(pgrep dockerd)`                 |                     |
| Disable debug in daemon.json | Change `"debug": false` in `/etc/docker/daemon.json` |                     |
| Verify debug flag only       | \`docker system info                                 | grep "Debug Mode"\` |

***

## Links and References

* [Docker Daemon Configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file)
* [Understanding the Docker Logging Driver](https://docs.docker.com/config/containers/logging/configure/)
* [Docker System Commands](https://docs.docker.com/engine/reference/commandline/system/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/docker-certified-associate-exam-course/module/871494af-49f8-42e9-95e9-cb0df80c2b21/lesson/dcebf7a4-f936-41e8-8c5e-930f34cb5b53" />
</CardGroup>
