Example blog

Install Dozzle, a simple log file viewer for Docker

[ad_1]

Docker is my go-to container deployment tool. I’ve always found it exponentially easier to use than, say, Kubernetes. Of course, Docker is not suitable for all deployments. However, when it comes to Docker, it’s unbeatable when it comes to simplicity, reliability, and stability. And then you launch Docker Swarm and you can scale to meet the needs.

But one thing that can still be quite difficult, even with Docker, is troubleshooting. With container deployments (especially full-stack applications), there are a lot of moving parts that can go wrong, and when something goes wrong, figuring out the culprit can be a real headache.

Log files are one of the best tools you have for troubleshooting Docker containers. Using log files will give you insight into your deployments, which is absolutely invaluable in keeping these containers running reliably and efficiently.

But how do you view Docker container logs? If you know the Docker command line, it’s not that difficult. For example, suppose you have deployed a container named mymongo (a MongoDB container) and you are having issues with the container. You can view the logs with the command:

You could get more details with:

You can also track the logs, which will continue to produce new information as events occur in the container. For this, the command is:

You can even view log entries before a specific timestamp, for example:

The above output only lists events that occurred up to 2 hours ago.

Depending on the complexity of the container, you might see a massive amount of output to sift through. And you may have many containers for which you need to view logs. What if you have more than 20 containers running on a server? Do you remember all the names of these containers? Otherwise, you will first need to locate the container name with the command:

With the name of the container in hand, you can then consult its logs.

It’s far from efficient, and since you’re working with containers, efficiency is the name of the game. That’s why there are tools like Dozzle, which offer a web UI for displaying Docker container logs. Trust me when I say that a tool like Dozzle will go a long way in making managing your Docker container much easier.

Let’s see how to deploy Dozzle and see how easy it is to view Docker container logs.

Installing Docker Community Edition

You probably already have Docker up and running (if not, why would you bother reading this)? In case you don’t, let me show you how you can install Docker Community Edition on Ubuntu Server 22.04.

The first thing to do is to add the official Docker GPG key with:

Next, we will add the official Docker repository with the command:

Install the required dependencies:

Update apt with the command:

Install Docker Community Edition with:

Make sure your user is a member of the docker group with the command:

Finally, log out and log back in for the changes to take effect.

How to deploy Dozzle

OK. Now is the time to deploy our web-based log viewer. To do this run the command:

Deploying the container shouldn’t take long. You can verify the deployment with the command:

You should see something like this:

Once the container is deployed, open a web browser and point it to http://IP:8888 (where IP is the IP address of the hosting server). You should see a simple interface that lists all running containers (Figure 1).

Figure 1: Dozzle’s web interface is clean and simple to use.

Click on any of these running containers to view the log file (Figure 2).

Figure 2: Dozzle showing mymongo container logs.

Figure 2: Dozzle showing mymongo container logs.

A really cool feature of Dozzle is the ability to upload your log files for a container. To do this, click on the three-dot menu in the upper right corner of an open log file and select Download. This will download the file (with .gz extension) to your local storage. You can then view the file with any text editor.

And that’s all there is to deploying the web-based Docker container log viewer Dozzle. If you have a significant number of containers to troubleshoot, this might just be one of the most efficient and convenient ways to do it.

Band Created with Sketch.

[ad_2]
Source link