Skip to main content
In this tutorial, you’ll learn how to manage Docker’s logging drivers—check the default, switch the daemon-wide setting, apply advanced options, and override the driver for individual containers.

1. Check the Default Logging Driver

Docker uses the json-file driver by default, storing container logs as JSON on the host.
The json-file driver is the standard Docker logging backend. It’s easy to parse and works out of the box.

2. Create and Inspect a Test Container

Run an Ubuntu container to see its inherited log configuration:
Inspect its log settings:

3. Supported Logging Drivers

Docker supports multiple logging backends for different use cases. You can find the full list in the official docs:
Configure containers → Logging
The image shows a section of the Docker documentation webpage, specifically listing and describing various logging drivers available for Docker containers.

4. Change the Default Driver to Syslog

To switch the daemon-wide driver to syslog, edit /etc/docker/daemon.json:
Modifying daemon.json requires restarting the Docker daemon. Existing containers will continue using their current driver until recreated.
  1. Stop Docker:
  2. Update /etc/docker/daemon.json:
  3. Restart Docker:
  4. Verify:

5. Advanced Logging Options

You can fine-tune log behavior with log-opts. For example, to limit file size and rotation on json-file:
Retrieve the current default driver in scripts:

6. Override the Logging Driver per Container

Even when the daemon default is syslog, you can pick a different driver for a specific container:
Confirm the override:

7. Conclusion

You’ve learned how to:
  • Check and view Docker’s default logging driver
  • Change the daemon-wide driver in /etc/docker/daemon.json
  • Apply advanced options like rotation and size limits
  • Override logging drivers for individual containers
Happy logging!

References

Watch Video