View your Docker Container Logs with Netdata

How to configure Docker to check container logs in Netdata with journald

View your Docker Container Logs with Netdata
Netdata Logo, systemd Logo, Docker Logo

Hey nerds 🤓

just a quick tip here. I am a big Netdata fan because it is a no-setup but full out of the box monitoring solution. I am not sure when, but Netdata also allows you to check your journald logs in their dashboard.

No need for other software or to log into your machine, you can also just look at those logs via your browser anywhere you want.

But what about docker logs?

That is actually super easy. You just have to change your docker log driver to journald:

  "log-driver": "journald"

You need to restart docker for the change to take effect:

sudo systemctl restart docker

Now, your already-running containers will still have the old logging driver. You can check this with:

docker inspect --format='{{.HostConfig.LogConfig.Type}}' caddy

You have to recreate the containers in order to change the log driver. With docker compose it's just a:

docker compose up -d --force-recreate

Now the log driver should be journald.

Checking logs

You can still run docker logs webserver but also journalctl CONTAINER_NAME=webserver . But I do not see a benefit to use journalctl instead of docker logs.

However, now you will have the field CONTAINER_NAME available in the Netdata log section and can check the container logs there:

Now you can check your logs on the go without needing to log in.


Another benefit of using the journald log driver is, that we have one tool which takes care of logs. Before Docker will take of Docker logs and systemd will take care of everything else. The problem is, that Docker logs can fill up the disk pretty quickly.
Now with journald we have one tool to take of logs and by default systemd will only write a maximum of 4GB logs to your disk. There is no way Docker logs will fill up the disk.

There are a bunch of configuration options for journald log size. Here are a few examples if you want to edit them to your use case:

SystemMaxUse=, SystemKeepFree=, SystemMaxFileSize=, SystemMaxFiles=, RuntimeMaxUse=, RuntimeKeepFree=, RuntimeMaxFileSize=, RuntimeMaxFiles=¶

You can read more here about journald config:

And here for reference the Docker log driver docs:

Last Words

How am I doing?

I love hearing from readers, and I am always looking for feedback. Is there anything you would like to read more or less of? You can just click on the 👍 or 👎 down below. What do you enjoy most about the newsletter, just let me know in the comments.

Have a great day! 👋