How to Install Dozzle in Docker to Watch Container Logs Live in Your Browser

How to Install Dozzle in Docker to Watch Container Logs Live in Your Browser

When one terminal stops being enough

Anyone running several containers on one VPS knows this scene. A web app suddenly returns a 500 error. You run docker logs -f on the app container, then realize the cause might live in the database container or the reverse proxy. The first terminal gets abandoned, a second one opens, the same command runs for the next container, and your attention splits across two scrolling windows. When a failing request crosses three services, reconstructing the order of events turns into guesswork.

Dozzle untangles that with a simple idea. It is a web-based Docker log viewer that streams container logs to your browser in real time. One tab shows the container list on the left and the log stream in the main pane. You can watch several containers side by side, search for a keyword while the stream keeps moving, jump to a specific timestamp, and check the same container's live CPU and memory usage without opening another window. There is no database to install and no log indexing pipeline to maintain. Dozzle reads straight from Docker Engine through the Docker socket and forwards whatever a container writes the moment it happens.

One limit deserves a clear statement up front. Dozzle is a log viewer, not a long-term log store. It does not archive old logs for analysis weeks later, and it does not replace a log aggregator when you genuinely need retention and historical queries. Its strength is diagnosis while an incident unfolds: when a container misbehaves, you see what it is writing right now.

This guide walks through installing Dozzle with Docker Compose on a VPS, from the simplest setup to the hardening steps that matter before the service faces a wider network. By the end, you will watch several containers at once from a browser, require a login, and place Dozzle behind a reverse proxy safely.

Prerequisites

You need a VPS or local machine already running Docker Engine 19.03 or newer, since Dozzle requires Docker API version 1.40 or later. Check with:

docker --version
docker compose version
docker info | head -20

This guide uses Compose V2 syntax (docker compose).

Make sure at least one other container is already running on the same host, so Dozzle has something to show on first launch. Any container will do. If none exists yet, start a throwaway example such as docker run -d --name example-web --restart unless-stopped nginx:alpine, which you can remove later with docker rm -f example-web.

This guide uses port 8080 on the host, matching Dozzle's default configuration. If another service already occupies that port, change the left-hand side of the port mapping during installation, for example to 8090:8080, and adjust the access address accordingly.

Finally, decide early whether Dozzle will stay on a local network or face the internet. Without authentication, Dozzle shows every container's logs to anyone who can reach its address. For internet access, authentication must be finished before the port goes public.

Step 1: Create the project folder and Compose file

Create a dedicated folder so Dozzle's configuration does not mix with other stacks:

sudo mkdir -p /opt/dozzle
cd /opt/dozzle

Then create docker-compose.yml with your editor of choice, for example:

sudo nano docker-compose.yml

Fill it with the following configuration, taken from Dozzle's official getting-started guide:

services:
  dozzle:
    image: amir20/dozzle:latest
    container_name: dozzle
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - dozzle_data:/data
    ports:
      - 8080:8080

volumes:
  dozzle_data:

Each of those three pieces shapes how Dozzle behaves. Mounting /var/run/docker.sock is how Dozzle reads the container list and log streams from Docker Engine; without it, Dozzle sees nothing. The dozzle_data volume mounted at /data stores Dozzle's settings, including user configuration once authentication is enabled, so settings survive container recreation. The 8080:8080 mapping forwards Dozzle's internal port to the same port on the host.

One warning from the official documentation is easy to underestimate. Access to docker.sock is effectively equivalent to root access on the host, so Dozzle must never sit open without authentication. Mounting the socket read-only (:ro) does not limit the Docker API the way many people expect: that flag only affects the socket file on disk, while API calls still pass through normally. Genuine restriction requires a dedicated socket proxy.

Save the file, then start Dozzle:

docker compose up -d

This pulls amir20/dozzle:latest, creates the dozzle_data volume, and runs the container in the background. If Docker Hub is blocked on your network, use the same image from GitHub Container Registry, ghcr.io/amir20/dozzle:latest, in the Compose file instead.

Check its status with docker compose ps and docker compose logs dozzle. You want to see the dozzle container in the Up state and startup logs free of repeating errors. If the container stops immediately, read its error output first; the usual culprits are port 8080 already in use or a missing Docker socket path.

Step 2: Open Dozzle and learn the layout

Open a browser and visit http://YOUR_SERVER_IP:8080, replacing YOUR_SERVER_IP with your VPS address, or http://localhost:8080 when Dozzle runs on the same machine. On a first visit without authentication, Dozzle shows its main interface right away: the container list on the left and the log area on the right, including stopped containers, so you can still inspect a container that just exited.

Click a container name. Its log stream appears immediately and scrolls automatically to follow the newest lines, with no refresh button involved. When you scroll up to read older lines, auto-scrolling pauses; scroll back to the bottom to resume following the live stream.

The stats panel for the selected container shows live CPU and memory usage, so one screen answers two questions at once: what the app is writing, and how much resource it is consuming.

Step 3: Search, filter, and watch several containers at once

This is where Dozzle starts feeling different from docker logs -f. Start with the search box at the top: type a keyword such as error, and Dozzle highlights matching lines while the stream keeps flowing. Search supports regex, so an HTTP status code or exception name can narrow results further. One limitation stated by the project itself: Dozzle does not do offline search over logs outside the streaming window.

For level-based filtering, use the level filter in the interface when the app writes structured logs. If your app writes JSON logs, Dozzle parses the fields and keeps multi-line stack traces grouped as one unit, rather than splitting them into hard-to-follow fragments.

Next, open the split-screen view for a second container: two or more log streams side by side. This is the most practical way to compare event order across services that call each other. A failed request in the web app can sit next to the database log from the same second, with no window switching and no manual timestamp matching across two terminals.

Dozzle can also show a merged log view from several containers, and on a multi-host setup, logs from different hosts can be combined into a single view.

Step 4: Turn on authentication with users.yml

Up to this point Dozzle runs without a login. This step changes that, using the simple file-based authentication provider built around users.yml. It fits well when you do not already run a central login service such as Authelia or Authentik. Dozzle's built-in command generates the file, including a bcrypt-hashed password, so the real password is never stored in plain text.

From a terminal in /opt/dozzle, generate a user file. The following creates a user named admin and prompts for the password interactively, keeping it out of your shell history:

docker run -it --rm amir20/dozzle generate admin --email admin@example.com --name "Admin" > users.yml

The official documentation notes an important detail: the command asks for the password on stdin and writes its prompt to stderr, so redirecting stdout to users.yml still produces a correct file. Replace the email and display name with your own, and avoid the --password flag on a shared server because the password would land in shell history.

Check the generated file:

cat users.yml

Its contents look roughly like this, with a different hash on your installation:

users:
  admin:
    email: admin@example.com
    name: Admin
    password: $2a$11$YOUR_BCRYPT_HASH_HERE

Next, mount that file into the container at the path Dozzle reads, /data/users.yml, and enable the simple provider. Edit docker-compose.yml to look like this:

services:
  dozzle:
    image: amir20/dozzle:latest
    container_name: dozzle
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - dozzle_data:/data
      - ./users.yml:/data/users.yml:ro
    ports:
      - 8080:8080
    environment:
      - DOZZLE_AUTH_PROVIDER=simple

volumes:
  dozzle_data:

One configuration trap is worth knowing: the dozzle_data volume and the users.yml file mount both target /data. If Dozzle still does not ask for a login after a restart, inspect /data from inside the container:

docker exec dozzle ls -la /data

If users.yml is missing there, fix the volume mapping and confirm the file exists at /opt/dozzle/users.yml on the host. Then recreate the container:

docker compose up -d

Reopen Dozzle's address. The login page should now appear; sign in as admin with the password you entered. Also test from a private window without logging in, and confirm the log pages refuse access before authentication succeeds.

For multi-user setups, the generate command supports officially documented extras: --user-filter limits which containers a user can see, while --user-roles limits what a user can do, for example viewing logs only without running container actions. Run docker run -it --rm amir20/dozzle generate --help to see all options before adding a second user. That scoping matters on a team: not everyone allowed to read logs needs to restart a production container from a browser.

Step 5: Keep actions and shell access off unless you need them

By default, Dozzle disables container actions and shell access, and that default is the safest place to stay unless you have a concrete reason to change it. Container actions let users stop, start, restart, and update containers from the interface menu. Shell access lets users open a shell inside a container from the browser. Both are useful, but both raise the stakes considerably if a Dozzle account is compromised.

If you genuinely need container actions, for example to restart a stuck service without opening a terminal, enable only that variable in the Compose file:

    environment:
      - DOZZLE_AUTH_PROVIDER=simple
      - DOZZLE_ENABLE_ACTIONS=true

Apply it with docker compose up -d, then check the actions menu on a selected container. If the menu does not appear, inspect the variables inside the container with docker exec dozzle env | grep DOZZLE and check for a typo in the variable name.

Shell access is a separate variable:

      - DOZZLE_ENABLE_SHELL=true

Treat the two decisions separately. Many teams need an occasional restart button but almost never need a browser shell on a production server. Enable them one at a time, only for users who truly need them, and only after authentication works.

Step 6: Put Dozzle behind a reverse proxy

When Dozzle needs a domain name, do not publish port 8080 straight to the internet. Place Dozzle behind a reverse proxy such as Nginx and let the proxy handle TLS. Dozzle streams logs over Server-Sent Events and uses WebSocket for the shell feature, so the proxy needs correct settings or the stream will stall.

The following Nginx example follows Dozzle's official reverse-proxy guide. Replace logs.example.com with your domain, and point proxy_pass at the Dozzle service:

server {
    listen 80;
    server_name logs.example.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_buffering off;
        proxy_cache off;
        chunked_transfer_encoding off;
    }
}

The last three directives decide whether logs flow or arrive in delayed bursts: proxy_buffering off disables response buffering, proxy_cache off disables caching for this location, and chunked_transfer_encoding off keeps chunked delivery aligned with streaming needs. Dozzle itself sends X-Accel-Buffering: no, but not every proxy honors it, so explicit directives remain necessary.

Once saved, test and reload Nginx with sudo nginx -t and sudo systemctl reload nginx, then secure the connection with TLS, for example via Certbot: sudo certbot --nginx -d logs.example.com. If logs stall after moving behind the proxy, suspect proxy buffering first, because that symptom almost always comes from the proxy layer.

Step 7: Watch other hosts with the Dozzle agent

A single Dozzle installation can watch more than one Docker host through agent mode. On the second host, run a Dozzle agent attached to that host's Docker socket and exposing port 7007. On the main installation, add a DOZZLE_REMOTE_AGENT variable pointing at the agent, for example:

    environment:
      - DOZZLE_AUTH_PROVIDER=simple
      - DOZZLE_REMOTE_AGENT=192.168.1.10:7007

Replace the example address with your agent host's real address, and separate multiple agents with commas when there is more than one. After recreating the main installation, the extra host appears in Dozzle's panel. The official documentation also supports a fuller address:port|name|group format for display names and groups.

This step is optional and best postponed until the single-host setup runs steadily. Make sure port 7007 is reachable only from the main host before adding a second agent.

Dozzle diagram

Dozzle versus docker logs and log aggregators

The following comparison puts Dozzle in its proper place, rather than treating it as a replacement for everything log-related.

Aspectdocker logsDozzleLog aggregator
AccessTerminal and SSHBrowser, one tabBrowser, query dashboard
Several containers at onceOne command per containerSplit screen and merged logsCross-service queries
SearchPiped to grepIn-interface search and filtersHistorical queries and aggregation
Log retentionFollows the Docker log driverNo archive keptStored and indexed long term
Maintenance costNoneOne small containerAn extra stack to maintain
Best forQuick check of one containerLive multi-container diagnosisAudits, trends, historical analysis

The sensible pattern: Dozzle as the everyday diagnosis tool, and a log aggregator only when retention or historical analysis genuinely becomes a need.

Common problems and fixes

SymptomMost likely causeFix
Empty container listDocker socket not mounted or unreadableCheck the /var/run/docker.sock volume in Compose and confirm Docker Engine is running
Container stops immediatelyPort 8080 already in useChange the mapping to 8090:8080 or stop the service using that port
No login prompt after enabling authenticationusers.yml not visible in /data inside the containerCheck with docker exec dozzle ls -la /data and fix the volume mapping
Login always rejectedWrong password or hash damaged by manual editingRegenerate users.yml with the generate command, never hand-edit the hash
Logs stutter behind a proxyProxy buffering or caching still activeApply proxy_buffering off and proxy_cache off, then reload the proxy
Old logs cannot be searchedDozzle keeps no log archiveUse a log aggregator for history
Container actions missing from the menuDOZZLE_ENABLE_ACTIONS not set or container not recreatedEnable the variable, run docker compose up -d, then check the menu

The time-saving diagnostic order: Dozzle container status, Dozzle's own logs, socket volume and port, then authentication or proxy configuration.

Final checklist

  • The dozzle container is Up and its startup logs are free of repeating errors.
  • Dozzle opens in a browser and lists the host's containers.
  • One actively logging container streams in real time without manual refresh.
  • Keyword search and a two-container split-screen view have both been tried.
  • users.yml was generated with the generate command and mounted at /data/users.yml.
  • The login page appears and unauthenticated access is refused.
  • Container actions and shell access stay disabled, unless a clear need exists to enable them.
  • When accessed from the internet, Dozzle sits behind a reverse proxy with HTTPS.
  • Settings persist in the dozzle_data volume after a restart.

Which container's logs do you open first when an incident hits, and does a side-by-side view change how fast you find the cause? Share it in the comments.

Read also: Companion article from the same batch and the article titled "Quick Trick: Docker Compose Logs and Log Rotation to Keep Your VPS Disk From Filling Up" to round out your Docker logging setup once Dozzle is running.

Diskusi

Ada pertanyaan atau pengalaman yang ingin dibagikan?

0komentar

Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.