In this quick project, we will be showing you how to set up a Docker log viewer called Dozzle.
Dozzle is a super lightweight web app aimed at making viewing the logs coming from your Docker containers in real-time easy. It can be a great alternative to using the Docker CLI to follow your container logs in real-time, especially when working remotely.
This tool has many features that allow you to easily browse through and view the logs output from your containers in real time. You can search the logs using regex, fuzzy search, and even SQL. Dozzle also has support for splitting logs across your screen, this is useful if you need to track what multiple containers are doing at the same time.
The only caveat of using Dozzle is that it is purely for handling live logs produced by your Docker containers. It doesn’t support reading logs from a file, so its crucial to keep Dozzle running.
One of the neat things about setting up Dozzle is that it itself is a Docker container. This means we can have you viewing the live logs of your Docker containers in just a few short minutes.
Please note that this container supports ARM-based systems, meaning you can even set up Dozzle on your Raspberry Pi if you want.
Setting up and Running Dozzle using Docker
Over the following sections, we will be walking you through the whole process of setting up and running Dozzle from a Docker container.
We will use a Compose file to make managing Dozzle a much simpler process. A Compose file is a file that contains instructions for Docker on how to run and manage a set of containers.
Preparing your System for Dozzle
1. The first part of this process is ensuring you have Docker installed on your machine. There is no point in using Dozzle if it has no Docker container logs to view.
If this is your first time using Docker, we have a great guide that shows you how to easily install Docker on most Linux operating systems.
https://pimylifeup.com/linux-docker-install/
2. Once Docker has been installed, we can create a directory to store the Compose file for Dozzle.
For this software, we will be making a directory at “/opt/stacks/dozzle
“. Keeping all your Compose stack files makes managing them easier down the track and helps them work out of the box with software like Dockge.
To create this folder, we will use the mkdir command alongside the “-p
” option. This option essentially tells Linux to create the full path.
sudo mkdir -p /opt/stacks/dozzle
3. Now that we have made a place to store the Compose file, change into the directory using the cd command.
cd /opt/stacks/dozzle
Writing a Docker Compose file to Run Dozzle
4. Once we are in the right place, we can begin writing the Docker Compose file that will set up and manage the Dozzle container on your Linux machine.
To write this file, we will be using Nano. It is a simple-to-use text editor, especially for beginners.
sudo nano compose.yaml
5. With the file now open for editing, type out the following lines. This basically tells Docker to download the Dozzle image from “amir20
“. We also mount the “docker.sock
” file to the container so that Dozzle can communicate with your other containers and retrieve their logs.
The final thing we do here is set the ports that Dozzle will utilize. With this we are exposing Dozzle on your host machine using port “8080
“. If you are using this port for a different service, change “8080
” on the left side to a different port number that isn’t in use.
services:
dozzle:
container_name: dozzle
image: amir20/dozzle:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 8080:8080
6. Once you have finished filling out the Compose file, you can save and quit by pressing CTRL + X, Y, and then ENTER.
Starting up the Dozzle Container
7. With the Compose file now written, all we need to do to start up the Dozzle Docker container is to run the following command within the terminal.
After running this, Docker will immediately download the “Dozzle” container and start it up. This process shouldn’t take very long as Dozzle is relatively small image.
By using the “-d
” option when running this command, Docker will detach from the
docker compose up -d
Viewing your Docker Container Logs in Real-Time with Dozzle
8. In your favorite web browser, you will want to go to the following address. Here, you will want to replace “<IPADDRESS>
” with the IP of your device. If you are running this on your current machine, then you can just use “localhost” instead.
If you have changed the port, you must replace “8080
” with that port.
http://<IPADDRESS>:8080
9. You should now have Dozzle up and running on your machine.
With this, you will get an overview of all the Docker containers and have the ability to quickly and easily view your conainers’ logs. This is a really simple interface to use. If you want to search the current logs, all you need to do is press CTRL + F on your keyboard.
Updating to the Latest Version of Dozzle
One of the key advantages of using Docker to run software like Dozzle is that updating to the latest release is a really simple process.
These next few steps will show you how easy it is to upgrade to the latest version of Dozzle. All you need is access to the terminal.
1. The first part of this update process is to change to the same directory where we wrote the Compose file earlier in this tutorial.
Assuming you stuck with the directories we used; you can change to the right place using the following command.
cd /opt/stacks/dozzle
2. Once we are in the correct directory, we will want to tell Docker to download the latest version of the Dozzle container.
All we need to do is to use the following command to pull the latest release. Please note this will only download the new version, it will not update the already running container.
docker compose pull
3. If a new version was downloaded, you only need to use the command below to get Docker to automatically restart Dozzle using the latest release.
You will get a brief downtime as the existing container is stopped and Docker makes the move to the new image.
docker compose up -d
Conclusion
By this stage in the tutorial, you should have the Dozzle Docker log viewer installed and running on your machine.
Dozzle is a great piece of software that makes viewing your logs in real-time a really simple process. Thanks to its added search functionality, it also makes finding important logs a much simpler and easier process than using the command line interface.
Please feel free to drop a comment below if you have had any issues with getting Dozzle running using Docker.
If you liked this tutorial, we highly recommend taking some time to explore some of the many other Docker guides we have.