🔥 Holiday Sale! 25% Off Platinum Membership and up to 50% Off on Deployarr (ends December 31).

Ultimate Docker Guides: Dozzle Docker Compose

Dozzle is used to monitor our Docker’s logs in real-time. In this Dozzle Docker Compose guide we’ll learn how to install/use Dozzle to simplify our troubleshooting tasks.

When we need to do some troubleshooting, in almost every IT-related work, the first and most important thing to do is CHECK THE LOGS.

Docker troubleshooting is no different, BUT we can do it in very different ways: manually check the logs from the command line. [Read: Basic Docker and Docker Compose Commands]

OR use some tools that simplify the task, perhaps with a nice web UI such as Dozzle.

In this Dozzle Docker Compose guide, we'll cover the second option.

What is Dozzle

Dozzle allows us to easily monitor in real-time our Docker container log, and also has a few strengths:

  • Prefect for beginners, as it has a very simple web-based interface.
  • Lightweight as it doesn't store any logs as it's used for real-time monitoring only.
  • Fast and requires few system resources to run.
  • Can be even configured to monitor multiple remote hosts with Dozzle agents.

Viewing Docker Container Logs On Dozzle
Viewing Docker Container Logs On Dozzle

Because of its advantages, Dozzle made it to our list of Best Docker Containers for Home Servers.

This guide will only focus on Dozzle standalone setups. In a future guide, we will cover how to monitor remote hosts with Dozzle agents.

Dozzle Docker Compose Installation

As always, before jumping straight to the configuration of the new container, we need to ensure that our working environment is correctly configured.

If your environment already aligns with Anand's configuration, you can safely skip the Requirements section. If your your setup is different, do not worry, we will make the guide generic enough to apply to other situations.

Requirements

Here is the list of guides that you can use to configure everything from zero or to update your existing configurations, as in this tutorial I'll use the same configuration.

I highly recommend to follow the newest Anand's guides:

Automated Homelab Setup with Docker Compose
Deployarr can install 100+ Docker Apps in minutes, including Traefik, Authelia, Starr Apps, and more. Everything discussed in this post is done automatically by Deployarr.
Deployarr App Logos 100 | Smarthomebeginner

Recapping Folder Structure

To recap, here is how our docker folder structure looks like:

  • /home/user/docker - Docker root folder is the folder that houses all the files related to our Docker stack, like the compose files, secrets, etc.
  • /home/user/docker/compose/hostname - Folder that contain all the individual compose files for various apps. hostname is the name of your docker host. If you followed Anand's Docker Media Server guide, this may be UDMS, as set in the .env file.
  • /home/user/docker/docker-compose-hostname.yml - The master docker compose file that brings all the individual compose files together.
  • /home/user/docker/.env - The environmental variables file.
  • /home/user/docker/secrets - The Docker secrets folder to house some of the sensitive info.

You can find a more detailed description of various Docker files and folders here.

What do you use or plan to use for viewing your Docker container logs?

View Results

Loading ... Loading ...

Dozzle Docker Compose Configuration

First, let's create a new file in the compose folder, I named it dozzle.yml but feel free to name it as you wish. This is where Dozzle Docker Compose will go.

You can find Dozzle and other Docker Compose examples in Anand's Github Repository.

Paste the following Docker Compose example for Dozzle:

services:
  # Dozzle - Real-time Docker Log Viewer
  dozzle:
    image: amir20/dozzle:latest
    container_name: dozzle
    security_opt:
      - no-new-privileges:true
    restart: unless-stopped
    # profiles: ["apps", "all"]
    networks:
      - default
      # - socket_proxy
    ports:
      - "8080:8080"
    environment:
      DOZZLE_LEVEL: info
      DOZZLE_TAILSIZE: 300
      DOZZLE_FILTER: "status=running"
      # DOZZLE_FILTER: "label=log_me" # limits logs displayed to containers with this label
      # DOCKER_HOST: tcp://socket-proxy:2375
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # Use Docker Socket Proxy instead for improved security

Save and close the file.

Customizing Compose for Dozzle

Here are some notes to understand and customize the above Dozzle docker-compose example:

  • We are using latest amir20/dozzle docker hub image.
  • We are naming the container dozzle but it can be anything you prefer.
  • Profiles, which is commented out right now, are a way to group the apps so one can stop, stop, or manage them together without affecting rest of the stack.
  • Dozzle will belong to the default network. This is fine for now. For advanced configurations, keep reading.
  • In the ports section, we are exposing port 8080 to the host, which is the default Dozzle port. Therefore, Dozzle will be available on the Docker host IP at port 8080. For example, if the Docker host has an IP of 192.168.1.111, then Dozzle will be available at http://192.168.1.111:8080.
  • Under volumes, we are exposing the Docker socket to allow Dozzle to monitor the containers. This is a minor security risk. If Dozzle is compromised then the attacker could gain control of the host system. Although not urgent, once you have your stack well established, I strongly recommend using Socket Proxy as described in Anand's Docker guide or YouTube video.

Customizing Network

In the above Dozzle Docker Compose file, we set the network as default. This is fine. Generally speaking, services belonging to the same network will be able to see each other on the ports they are listening at. So, if you want to improve security and use Docker Socket Proxy instead then both services should be on the same network.

Host Network

Alternatively, you can specify the Dozzle Docker container to use the host network. In this case, Dozzle functions as if it were running natively on your host system. This requires all necessary ports to be free (e.g. 8080). To enable host networking, use the following block instead of networks:

    network_mode: 'host'

In addition, you will also need to remove the ports section. Dozzle should be available at http://192.168.1.211:8080, which is the same URL as the default Dozzle docker compose setup shown previously.

If for whatever reason, port 8080 is not free, you could specify a custom port on the host side (e.g. 8081:8080) or use Macvlan as described below.
Dockervlan / Macvlan

Another option is to use Macvlan.

This makes the Dozzle container appear as a separate machine (even though it is just a container on the Docker host) on the same network as the Docker host, with its own IP (e.g. 192.168.1.112). This also avoids any port conflicts with the Host machine.

Other Networks

If you decide to use Socket Proxy instead of exposing Docker Socket directly to Dozzle, then you will have to make the Dozzle container part of the socket_proxy network. This is commented out right now.

If you do so, then you may also configure DOCKER_HOST variable and comment out the Docker Socket volumes.

Environment Variables

VariableExplanation
DOZZLE_LEVELinfo is the default log level and shows logs only, debug and trace will show additional details like memory, configuration and other stats.
DOZZLE_TAILSIZEThe number of log lines to show at a time.
DOZZLE_FILTERFilters for the monitored containers, in our case we'll monitor only the running ones.
More info on filters here.
DOCKER_HOSTSet this to tcp://socket-proxy:2375 if you are using Docker Socket Proxy. Since both services belong to the same network, Dozzle can reach Socket Proxy using the TCP port 2375 and using the container host name, which is socket-proxy.

Add Dozzle Container to the Docker Stack

If you have one big docker compose file, you may add Dozzle Docker Compose right under the services: block of the existing Docker Compose file. If you have been following Anand's guides (or Deployarr), then you have to do it a bit differently.

After creating the Dozzle yml file, we need to add its reference to the main Docker Compose file (/home/user/docker/docker-compose-udms.yml), right under the include section:

include:
  - compose/$HOSTNAME/dozzle.yml

Save and close the file. $HOSTNAME is automatically pulled from the Docker host. So, don't worry about it.

Start Dozzle Container and Test

Now that we have added the Dozzle docker compose to the main Docker Compose file, start it using the following command:

sudo docker compose -f /home/user/docker/docker-compose-udms.yml up -d dozzle
If you enable Docker Profiles, then be sure to include --profile all in the above command: sudo docker compose --profile all -f /home/user/docker/docker-compose-udms.yml up -d .

Otherwise, you will see no service selected error.

Visit http://DOCKER-HOST-IP:8080 to access Dozzle web interface.

DOCKER-HOST-IP is the IP of our Docker Host, where our containers are running, and has nothing to do with the value of the environment variable DOCKER_HOST!

If you wish to simplify Docker and Docker Compose commands, then be sure to implement Anand's Docker Bash Aliases.

Viewing Logs with Dozzle

The first page displays:

  • The details of the docker host (Total CPU, Total RAM, Number of containers, and Docker version), and its consumption of CPU and RAM
  • The list of all the containers, only the running ones due to the DOZZLE_FILTER configuration as seen previously, with their consumption of CPU and RAM.

Dozzle Main Page
Dozzle Main Page

Clicking on the container's name, the details regarding its resource consumption (RAM and CPU) and obviously the logs are shown:

Dozzle Detail Page
Dozzle Detail Page

The various logs are shown next to their timestamps, that can be clicked to show the filter section, where we can decide what information to show, what not and even ordering them with a simple drag-and-drop:

Dozzle Filter Section
Dozzle Filter Section

Last but not least, the Search function can be activated with the classic keyboard shortcut CTRL+F, and allows us to, guess what.... search through logs!

Dozzle Search Function
Dozzle Search Function

Accessing Dozzle Over the Internet

We have various options to access the Dozzle dashboard from outside our LAN:

Port Forwarding - Least Secure Method

The classic (and less secure) method, which consists of forwarding an external port of our router/modem/firewall/Internet facing device/..., directly to the corresponding port of the Dozzle container, 8080 in this case, on our Docker Host.

Over Mesh Networks - Easiest Method

By far the easiest and most secure method is to use an Overlay Mesh Network such as Tailscale or Zerotier.

Here are Anand's videos on how to use them:

Reverse Proxy - Most Flexible

Reverse Proxy such as Nginx Proxy Manager, Caddy, HAProxy, or Traefik are good methods that includes practicality, customization, and security.

Traefik is our choice as a reverse proxy. You may learn more about it using the links below:

With this configuration, we can reach our Dozzle dashboard or status pages through an address like https://dozzle.ourdomain.org.

Wireguard/VPN - Most Private Method

Safer than opening ports and more private than trusting third-parties, with Wireguard, we can access Dozzle through our own VPN.
You can find everything you need for Wireguard, which I highly recommend, here:

Other Posts in the Wireguard Series:

Securing Dozzle

There are many ways to secure our Dozzle container to avoid unwanted access:

I've only reported methods that we had personally tested, to guarantee functionality and provide guides that allow you to install and configure them correctly.

FAQ

Few frequently asked questions while setting up Dozzle using Docker-Compose.

How to change log level in docker container?

This depends on the Docker image that is being used. If the image supports debug logging then one can use the docker-compose logs command to see the logs or a log viewer like Dozzle.

Which logging driver is best for docker?

By default, Docker uses the JSON-file logging driver. It caches container logs as JSON. This is the recommended logging driver. Other types of logging drivers can be enabled using plugins.

How to check logs inside docker container?

Logs inside docker containers can be checked using the docker logs command or docker-compose logs command. Alternatively, an app such as Dozzle log viewer can be used.

Are there any Dozzle alternatives?

Dozzle does what it meant to do well. There are no 1-to-1 alternatives but Portainer also has a built-in log viewer. Portainer can be a Dozzle alternative but it is much more powerful than that.

Conclusions: Dozzle on Docker

Dozzle is one of the first apps I install while building a docker stack. It is a powerful logs viewer and has made it very easy for me to follow the logs as I experiment, and star/stop by containers/stacks. You cannot install it natively on the OS.

But Docker makes it much easier to install Dozzle, and Docker Compose simplifies it even more. With the included Docker Compose for Dozzle and easy steps to set up Dozzle, you should be up and running in just about 5 minutes.

So, if you are new to docker or just need a GUI to view your docker logs, go ahead and use the included Dozzle docker-compose.

Be the 1 in 200,000. Help us sustain what we do.
125 / 150 by Dec 31, 2024
You will gain benefits such as Deployarr access, discord roles, exclusive content, ad-free browsing, and more.
🔥 Holiday Sale! 25% Off Platinum Membership $399.99 $299.99 (ends December 31).
Join the Geek Army (starting from just $1.67/month)
Holiday Sale