Dozzle Docker Compose: Simple Docker Logs Viewer

Dozzle is a realtime log viewer for docker, which simplifies troubleshooting. This Dozzle Docker Compose guide shows you how to get started with Dozzle in minutes.

When I started with Docker, there was no Dozzle. I had to check the Docker container logs using commandline. It wasn't bad but it was easy either.

Then Dozzle came along and it made it easier for beginners to get started with Docker. This is why I made it a part of my Docker media server guide.

Dozzle is a lightweight, web-based Docker log viewer that provides real-time monitoring and easy troubleshooting.

If you are just getting started or experimenting a lot with Docker containers then, in my opinion, Dozzle is a must-have tool to simplify your workflow.

Dozzle is one of the apps that made it into our list of best Docker containers.

In this guide, I will present a Dozzle Docker-Compose file that I use in all of my stacks.

What is Dozzle

Dozzle allows you to view logs of other Docker containers in real time. The logs are streamed to a web interface without the need to refresh the page.

Viewing Docker Logs In Dozzle
Viewing Docker Logs In Dozzle

In its infancy, it was not much more than a log viewer. Over time, I have seen very nice improvements in the UI, and new monitoring features such as memory and CPU information, color scheme, etc. These have made Dozzle look more polished.

It is written in Go and uses minimal resources to run. Docker Dozzle even allows connecting to different hosts, giving you a central place to monitor all Docker logs.

Dozzle Docker Compose Setup

Dozzle runs only on Docker. Most Docker tutorials out there give you the Docker run command and ask you to copy-paste it into Portainer, which can also serve as a great Dozzle alternative. [Read: Portainer Docker Compose: FREE & MUST-HAVE Container Manager]

In this Dozzle docker install guide, we will use Docker Compose to set up Dozzle. Having used Docker for over 5 years (and being a person of non-IT background), I strongly suggest you take the time to learn Docker compose and build your stack using it.

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

View Results

Loading ... Loading ...

Docker Compose gives you portability between systems. I can use the docker-compose files from my GitHub repo in my Ubuntu Server on Proxmox, my Ubuntu Server VPS on Digital Ocean, or even my Synology NAS and they will work the same.

1. Prepare to Setup Dozzle Using Docker

If you already have docker and docker-compose installed, then skip to Docker Compose for Dozzle section below.

Requirements

First, let us start with some requirements. I won't go into a lot of details as these have been covered in detail in my Docker Media Server guide. Here is a summary of the requirements before Proceeding.

Setting Up The Docker Environment

This is also explained in detail in my Docker Guide. We are going to customize a few things with Docker before building the Dozzle Docker Compose file.

First, is the folder structure. I like to house all of the docker-related files and folders in one location. I call it the Docker Root Folder. Our docker-compose.yml, .env files, etc. will be located in this folder, as shown below.

Docker Media Server Folder Structure
Docker Media Server Folder Structure

For this guide, you do not need to worry about the folders in the above screenshot, as we won't be defining any persistent storage volumes for Dozzle Docker container.

2. Create the Base Dozzle Docker Compose File

Before we go ahead and add the Docker Compose for Dozzle, we will have to add a few basic elements to the compose file. Once again, this is all explained in detail in my Docker tutorial. But here is a summary of it.

Note that spacing and indentation are crucial in YAML files. Therefore, pay attention to the formatting when you copy-paste and customize the Dozzle Docker Compose snippet.

In your Docker Compose file, if you do not already have it, add the following:

version: "3.9"

########################### NETWORKS
networks:
  default:
    driver: bridge

########################### SERVICES
services:

We are specifying the version of Docker Compose reference to use and the default Docker bridge network. If you do not know what these are, do not worry.

We are going to make Dozzle accessible using the Docker Host machine's IP, using Dozzle's default port (e.g. http://192.68.1.211:8080). For this purpose, the above network block is sufficient.

3. Docker Compose for Dozzle

Here is the Docker-Compose for Dozzle that I use. Add it right under services (pay attention to indentation):

  # Dozzle - Real-time Docker Log Viewer
  dozzle:
    image: amir20/dozzle:latest
    container_name: dozzle
    restart: unless-stopped
    networks:
      - default
    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 # enable when using socket proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # disable when using socket proxy
You may find that the Docker Compose examples in my GitHub repo differ from the above. What is shown above is an example that is good for beginners to get started with. What is in my GitHub repo is my current setup with many features and security enhancements.

Customizing Dozzle Docker Setup

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

  • We are using latest amir20/dozzle:latest docker image.
  • 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, my Docker host has an IP of 192.168.1.211. So Dozzle will be available at http://192.168.1.211:8080.
  • Next, we set some environmental variables such as logging level for Dozzle logs viewer, how many lines of logs to tail, showing only running containers, etc. By default Dozzle Docker monitors all containers, you could limit it only containers having a specific label.
  • Optionally, you could specify the Docker host if using a socket proxy.
  • 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 my Docker best security practices article.

Customizing Network

In the above Dozzle Docker Compose file, we set the network as default. This is fine.

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 take a look at macvlan networking for docker.

4. Start Dozzle

After customizing the Dozzle Docker Compose file, you can start Dozzle using the following command:

sudo docker compose -f ~/docker/docker-compose.yml up -d

Be sure to refer to my Docker guide to understand how you can follow the logs to check the start-up of the Dozzle docker container. If all goes well, in a few minutes you should be to access Dozzle Docker containers list.

Dozzle Docker Compose
Dozzle Docker Containers List

5. Accessing Dozzle Over The Internet

Accessing Dozzle from within your home network should work fine (described above). But what if you want access to Dozzle logs viewer on the go from outside your home network?

Well, there are many ways to do this.

The easiest and NOT RECOMMENDED way to do this is to forward port 8080 on your router/gateway to point to your Dozzle servers IP address.

Accessing Dozzle with VPN

A secure way to access Dozzle is to connect to your home network using a VPN service. Home routers and network-attached storage devices sometimes come with a built-in VPN server. Once connected, you can use the same home network IP address of your Dozzle Docker server.

You may also use a third-party VPN mesh network such as Tailscale or Zerotier-One. I use ZeroTier to tie all my key machines together in a virtual network. My Docker host is part of this network. Therefore, while on the go, I can use my Docker host's ZeroTier network IP address with Dozzle's port number.

Another alternative is to set up your own Wireguard network. But this is a more advanced topic.

Other Posts in the Wireguard Series:

Exposing Dozzle with Reverse Proxy

Another secure way to access Dozzle is to put it behind a reverse proxy. But this requires a domain name or a DDNS.

Nginx Proxy Manager is very simple to setup but not very flexible.

I use and recommend Traefik. You can read all about setting it up in my Docker Traefik guide or refer to my GitHub repo.

With a reverse proxy, you can access Dozzle using a nicer URL (e.g. https://dozzle.example.com) - this is what I do.

6. Securing Dozzle

By default, Dozzle does not include an authentication system. You can enable a simple authentication using username and password as described here. However, you still won't have SSL enabled and will have the risk of username and password being sniffed.

I highly recommend better security with SSL and multifactor authentication, which can be achieved in many ways.

This is where the power of Traefik over Nginx Proxy Manager becomes evident. You could integrate Google OAuth or Authelia Self-hosted MFA, very easily.

Once configured, you will have the option to log in using a much stronger authentication system.

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.

Did this post help you?
SmartHomeBeginner brings in-depth tutorials easy enough to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
  • Feeling generous? Become a Sponsor (discounted options) or a Patron. You will receive privileges on our Discord Server.
  • Just want to thank us? Buy us a Coffee or a Ko-Fi.
  • May be another day? Shop on Amazon using our links. Your prices won't change but we get a small commission.
  • Don't feel like spending? You can still show your support by sharing this post, linking to it in forums, or even commenting below.

Anand

Anand is a self-learned computer enthusiast, hopeless tinkerer (if it ain't broke, fix it), a part-time blogger, and a Scientist during the day. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs.