amir20 / dozzle

Realtime log viewer for docker containers.
https://dozzle.dev/
MIT License
6.2k stars 309 forks source link

Container grouping not persistent #3266

Closed cr0n76 closed 1 month ago

cr0n76 commented 2 months ago

🔍 Check for existing issues

How is Dozzle deployed?

Standalone Deployment

📦 Dozzle version

v8.4.3

✅ Command used to run Dozzle

services:
  dozzle:
    container_name: dozzle
    image: amir20/dozzle:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 9999:8080

🐛 Describe the bug / provide steps to reproduce it

If I start a multiple container via an docker compose file, all respective containers are stacked together in the Dozzle UI. e.g Paperless here: image and image

This behavior is fully expected and consistent with how I understand https://dozzle.dev/guide/container-groups

If I start a docker-compose with only one container, it will be shown with the same stacking logic, e.g. Calibre here: image

This behavior is not expected per se, but appreciated by me nevertheless. However, If I reload the dozzle frontend (webpage), it will be sorted into "all containers" again: image

It is unexpected that the stacking logic changes after reloading the page.

If I add labels as per https://dozzle.dev/guide/container-groups, e.g.

    labels:
      - dev.dozzle.group=calibre

the behavior is the very same as above. Actually, with this labels set I would expect the behavior described above, but persistent.

Additional: if I add

name: calibre

Dozzle will add the Swarm-Mode switch. However Swam-Mode would aggregate ALL logs into one stream, which is not what I want.

💻 Environment

Synology DS218+

📸 If applicable, add screenshots to help explain your bug

No response

📜 If applicable, attach your Dozzle logs. You many need to enable debug mode. See https://dozzle.dev/guide/debugging.

No response

amir20 commented 2 months ago

If I start a docker-compose with only one container, it will be shown with the same stacking logic, e.g. Calibre here:

The bug actually seems to be this. Dozzle doesn't group single containers regardless of their label. This was done intentionally as N containers with single groups would have N groups which seemed bad UX. This was discussed in length when I first implemented grouping.

However, If I reload the dozzle frontend (webpage), it will be sorted into "all containers" again:

This is the intended behavior. I am not sure why it requires a reload. I can't think of any reason. I would have to try to replicate.

It is unexpected that the stacking logic changes after reloading the page.

Yes agreed.

If I add labels as per https://dozzle.dev/guide/container-groups, e.g.

Yes, the logic for compose, swarm and custom groups is the same. So I would expect it to do the same.

Dozzle will add the Swarm-Mode switch. However Swam-Mode would aggregate ALL logs into one stream, which is not what I want.

I didn't understand this. In swarm mode, everything is shown as services and stacks.

I think the only bug in this issue might be why a page reload is needed for the intended behavior to be displayed.

cr0n76 commented 2 months ago

Thanks for the answer. I agree, that it might be considered bad UX if N containers are in N groups. As I wrote, I would not expect this behaviour out of the box as well.

However I disagree that the logic for compose, swarm and custom groups should be the same. The grouping-logic for compose and swarm makes perfect sense. But if I take the effort to manually add special labels to all my compose yamls (or all my commands to start containers) to actively sort N containers into N groups I expect that N containers will be sorted into N groups - as I did this on purpose.

However I agree that this might be a UX-detail 95% of the users might not even think about. And you are developing this in your free time. Thanks for this great project!

(And I see that my text about swarm might be incomprehensible. Just ignore it as it's not in the focus anyhow)

amir20 commented 2 months ago

However I disagree that the logic for compose, swarm and custom groups should be the same. The grouping-logic for compose and swarm makes perfect sense. But if I take the effort to manually add special labels to all my compose yamls (or all my commands to start containers) to actively sort N containers into N groups I expect that N containers will be sorted into N groups - as I did this on purpose.

I think I misspoke. This is only true when Dozzle is in host menu. In swarm mode, it should do what you suggested. If you created N groups then it should be N groups.

Is that not the case? If you give me an example sample compose file I can test it.

amir20 commented 2 months ago

I tested wtih docker run -d --label dev.dozzle.group=test ... that it does create a group in swarm mode even with just one container. Is that right?

undaunt commented 2 months ago

Hey all,

Just catching up on this. Non swarm mode, if I were to break out various groups of apps I have into stacks, but some of the stacks have 1 app and some have 2+ apps, only the apps with 2+ would show in stacks and the rest would show in 'running containers/all containers' then regardless? This is intended?

My goal would be to have every stack show separately regardless of how small the stack is, or at least force that as an optional flag, if possible. Thank you for your consideration.

amir20 commented 2 months ago

Just catching up on this. Non swarm mode, if I were to break out various groups of apps I have into stacks, but some of the stacks have 1 app and some have 2+ apps, only the apps with 2+ would show in stacks and the rest would show in 'running containers/all containers' then regardless? This is intended?

Yes that is intended. Dozzle doesn't break out to groups until there is at least 2. A group with just one container doesn't provide any value.

My goal would be to have every stack show separately regardless of how small the stack is, or at least force that as an optional flag, if possible. Thank you for your consideration.

Why? Is there a functionality that you would want that is provided with groups? As far as I can tell, there isn't any value. And I would rather not provide a toggle for this. It's too much complexity for each toggle that is introduced.

cr0n76 commented 2 months ago

I tested wtih docker run -d --label dev.dozzle.group=test ... that it does create a group in swarm mode even with just one container. Is that right?

Well, I don't know. Two days ago it appeared to do exactly this, but to merge all logs into one stream, and not to offer seperate logs in a group in swarm mode. Additionally to force the swam mode switch to appear, I needed to add the name: [name] line in all docker-compose.ymls.

However, when I tried to replicate it today the swarm mode is not appearing again.

I added

labels:
  - dev.dozzle.group= [name]

and

name: [name]

to all my docker-compose-ymls and the swarm mode switch is not appearing again. Weird...

I like that undaunt expects to be able to group single containers as well. I understand that some people might not see the benefit, but for me this helps finding the correct container faster. Therefore I thought its a good solution that normally this should not be the case but if I manually group containers with labels, then I should be able to achieve this.

amir20 commented 2 months ago

I guess I am having a hard time understanding this issue, @cr0n76.

Additionally, to force the swarm mode switch to appear, I needed to add the name: [name] line in all docker-compose.yml files.

I don't think this is true. If there are any services, stacks, or custom groups, this should happen.

If you can help provide a compose file with Docker and some tests, then I can test it out.

Admittedly, I don't have a lot of time, and I may be missing something here.

So please help me reproduce this.

cr0n76 commented 1 month ago

I guess I am having a hard time understanding this issue, @cr0n76.

Additionally, to force the swarm mode switch to appear, I needed to add the name: [name] line in all docker-compose.yml files.

I don't think this is true. If there are any services, stacks, or custom groups, this should happen.

If you can help provide a compose file with Docker and some tests, then I can test it out.

Admittedly, I don't have a lot of time, and I may be missing something here.

So please help me reproduce this.

Thanks for your patience, the kids needed too much attention at the weekend. So I do not know exactly how much you would expect. I will add three docker compose yamls. I'm especially not sure what kind of tests you expect. If I start all three docker compose projects the swarm-switch is not popping up. Especially not if i remove either the name: ... or the labels: ... lines in any of them one by one.

may expectation would be (after your explanation) that the swarm-switch should appear if only one single of the name: ... or labels: ... is present in the yamls. But all alternations between only one single entry or all lines in all yamls do not cause the switch to appear. Additionally this was working before with the current version of dozzle (when all deployed yamls had the name:... line in them). I have no idea why it is not working anymore.

name: dozzle
services:
  dozzle:
    container_name: dozzle
    image: amir20/dozzle:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 9999:8080
    labels:
      - dev.dozzle.group = dozzle
name: calibre
services:
  calibre:
    image: linuxserver/calibre:latest
    container_name: calibre
    security_opt:
      - seccomp:unconfined
    environment:
      - PUID=1026
      - PGID=100
      - TZ=Europe/Berlin
    volumes:
      - /volume1/docker/calibre/data:/config
    ports:
      - 7080:8080
      - 7081:8081
    labels:
      - dev.dozzle.group = calibre
    restart: unless-stopped
# Docker Compose file for running paperless from the docker container registry.
# This file contains everything paperless needs to run.
# Paperless supports amd64, arm and arm64 hardware.
#
# All compose files of paperless configure paperless in the following way:
#
# - Paperless is (re)started on system boot, if it was running before shutdown.
# - Docker volumes for storing data are managed by Docker.
# - Folders for importing and exporting files are created in the same directory
#   as this file and mounted to the correct folders inside the container.
# - Paperless listens on port 8000.
#
# In addition to that, this Docker Compose file adds the following optional
# configurations:
#
# - Instead of SQLite (default), PostgreSQL is used as the database server.
# - Apache Tika and Gotenberg servers are started with paperless and paperless
#   is configured to use these services. These provide support for consuming
#   Office documents (Word, Excel, Power Point and their LibreOffice counter-
#   parts.
#
# To install and update paperless with this file, do the following:
#
# - Copy this file as 'docker-compose.yml' and the files 'docker-compose.env'
#   and '.env' into a folder.
# - Run 'docker compose pull'.
# - Run 'docker compose run --rm webserver createsuperuser' to create a user.
# - Run 'docker compose up -d'.
#
# For more extensive installation and update instructions, refer to the
# documentation.
name: paperless
services:
  broker:
    user: "1026:100"
    container_name: paperless-redis
    image: redis:7
    restart: unless-stopped
    volumes:
      - /volume1/docker-databases/paperless-ngx/redis-data:/data
    labels:
      - dev.dozzle.group = paperless

  db:
    container_name: paperless-db
    image: postgres:16
    restart: unless-stopped
    volumes:
      - /volume1/docker-databases/paperless-ngx/db:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: removed
      POSTGRES_USER: removed
      POSTGRES_PASSWORD: removed
    labels:
      - dev.dozzle.group = paperless

  webserver:
    container_name: paperless-webserver
    image: ghcr.io/paperless-ngx/paperless-ngx:latest
    restart: unless-stopped
    depends_on:
      - db
      - broker
      - gotenberg
      - tika
    ports:
      - "8000:8000"
    volumes:
      # database folders
      - /volume1/docker-databases/paperless-ngx/data:/usr/src/paperless/data
      # media folders
      - /volume1/docker/paperless-ngx/archive:/usr/src/paperless/media/documents/archive
      - /volume1/docker/paperless-ngx/export:/usr/src/paperless/export
    env_file: docker-compose.env
    environment:
      PAPERLESS_REDIS: redis://broker:6379
      PAPERLESS_DBHOST: db
      PAPERLESS_TIKA_ENABLED: 1
      PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000
      PAPERLESS_TIKA_ENDPOINT: http://tika:9998
      PAPERLESS_ADMIN_USER: removed
      PAPERLESS_ADMIN_PASSWORD: removed
    labels:
      - dev.dozzle.group = paperless

  gotenberg:
    container_name: paperless-gotenberg
    image: gotenberg/gotenberg:8.7
    restart: unless-stopped

    # The gotenberg chromium route is used to convert .eml files. We do not
    # want to allow external content like tracking pixels or even javascript.
    command:
      - "gotenberg"
      - "--chromium-disable-javascript=true"
      - "--chromium-allow-list=file:///tmp/.*"
    labels:
      - dev.dozzle.group = paperless

  tika:
    container_name: paperless-tika
    image: apache/tika:latest
    restart: unless-stopped
    labels:
      - dev.dozzle.group = paperless

edit: I additionally tried docker system prune in the hope to remove any dangling things that might prevent the expected behavior, but it did not change anything.

What might be of interest is that I am using Dozzle on a Synology NAS, which have a quite old docker / docker compose version. But as they have horrific log functionality Dozzle is especially useful on them:

Client:
 Version:           20.10.23
 API version:       1.41
 Go version:        go1.19.1
 Git commit:        876964a
 Built:             Fri Sep  8 08:19:48 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Docker Compose version v2.9.0-6413-g38f6acd

undaunt commented 1 month ago

@amir20 Regarding the single app toggle, consider my apps that are currently online.

image

If I were to shrink down the Traefik and Music stacks, etc. I would want Portainer to be between them, alphabetically and quickly grabbable. I have this today when I put everything in one master stack, and I will wind up with a lot of unrelated, one app stacks under 'all containers'.

Thanks for considering.

cr0n76 commented 1 month ago

Short Update: I pulled the newest release of Dozzle and there is no change in the above mentioned behavior (what is somehow expected since the commits for the latest release do not include a specific fix for this issue).

amir20 commented 1 month ago

That's right, I haven't had a chance to look at this. @cr0n76 I was hoping you would give me a set of docker run commands to try to get it to not work. I can't really use your docker compose file as it requires setting up volumes.

@undaunt having single containers not in a group was long debate that happen a while back. The point was that if there is a lot of single group containers then it would be a very long list. So the decision was to group only when there is at least 2. I don't think I want to support a toggle here and this is a side project. I already get a lot of bugs and keeping things simple is better for me.

@cr0n76 I'll try some tests when I get a chance and come back to see if I can reproduce this.

cr0n76 commented 1 month ago

That's right, I haven't had a chance to look at this. @cr0n76 I was hoping you would give me a set of docker run commands to try to get it to not work. I can't really use your docker compose file as it requires setting up volumes.

@undaunt having single containers not in a group was long debate that happen a while back. The point was that if there is a lot of single group containers then it would be a very long list. So the decision was to group only when there is at least 2. I don't think I want to support a toggle here and this is a side project. I already get a lot of bugs and keeping things simple is better for me.

@cr0n76 I'll try some tests when I get a chance and come back to see if I can reproduce this.

Well, all my containers are deployed with docker compose. I did not start any of them with docker run. I am not sure if testing with docker run really helps? I can try to exchange the bind mounts with docker volumes if that helps?

However, As I do not intend to use the swarm mode, I am not sure how high you should prioritize this whole thing...the bug we are talking about is not the initial bug of this bugreport. So you would fix it for you, not for me.

If you want to spend time to help my usecase you could alter the grouping logic, that even single containers would be grouped in the normal web view in case the dev.dozzle.group lable is set appropiatly.

amir20 commented 1 month ago

I am little confused. What is the bug we are talking about? I was under the impression that sometimes "Swarm Mode" doesn't show up even when it is supposed to be.

Is the bug that it should be grouped even with on container in a group? If that's the bug, then we can close because I don't expect to revisit that.

Can someone summarize what is not working and how I can reproduce it? If nothing then I can close.

cr0n76 commented 1 month ago

I am little confused. What is the bug we are talking about? I was under the impression that sometimes "Swarm Mode" doesn't show up even when it is supposed to be.

Is the bug that it should be grouped even with on container in a group? If that's the bug, then we can close because I don't expect to revisit that.

Can someone summarize what is not working and how I can reproduce it? If nothing then I can close.

The initially reported Bug: Dozzle do not persist grouping of single containers. Your answer: Dozzle is meant to not group single containers. The actual bug is that Dozzle shows single grouping in some cases until its reloaded. I can reproduce the latter with my provided docker compose yamls. I don't know if you can reproduce it.

Further you said that swarm mode fulfills my expected behavior, but my memory says otherwise. This leads to the third bug: I can't trigger swarm mode to check this. Whatever I do, it will not appear. Again my compose yamls would lead to this behavior on my machine.

These are the bugs. On my machine I can reproduce them with the provided docker compose yamls. You can decide what you will fix.

To be honest: docker logs on the Synology UI feel like a horror beyond comprehension. The actual benefit is Dozzle itself, not the sorting logic. You would not lose me as user if you don't fix any of this things. Even though grouping of single containers in host mode would really help me to find containers faster, and I still believe that if user specifically manually apply any sorting logic, the UI / UX should follow.

amir20 commented 1 month ago

Thanks for the detailed write up..

The initially reported Bug: Dozzle do not persist grouping of single containers

Yes, I think the actual bug is reloading. I haven't been able to reproduce that yet but will try soon.

I can't trigger swarm mode to check thi

I plan to use your compose file and replace each service with a dummy container. Since labels are the same I think it would be easier.

amir20 commented 1 month ago

Ok update on this. Replicating your compose file is too hard and I was hoping you could create a simpler example. However, I was able to copy your compose file and replace with a dummy image:

name: paperless
services:
  broker:
    image: amir20/echo
    command: -r
    labels:
      - dev.dozzle.group = paperless
  db:
    image: amir20/echo
    command: -r
    labels:
      - dev.dozzle.group = paperless
  webserver:
    image: amir20/echo
    command: -r
    labels:
      - dev.dozzle.group = paperless
  gotenberg:
    image: amir20/echo
    command: -r
    labels:
      - dev.dozzle.group = paperless
  tika:
    image: amir20/echo
    command: -r
    labels:
      - dev.dozzle.group = paperless

I see this:

Screenshot 2024-09-20 at 9 35 58 AM

The grouping is right, but for some reason the custom label is not working.

Then I realized you have dev.dozzle.group = paperless and not dev.dozzle.group=paperless. So I tried that and now I see:

Screenshot 2024-09-20 at 9 37 36 AM

Clicking the toggle shows a custom stack as expected.

Screenshot 2024-09-20 at 9 37 53 AM

At no point did I notice a reload was required. Everything seemed to work smoothly.

And finally, since you are not using swarm mode then I would not expect to see the toggle until you use swarm or a custom label. Swarm menu expects at least one service which you don't have with docker compose up.

Seems like everything works as expected ✅

amir20 commented 1 month ago

I found the original bug that discussed the grouping logic. You can see the comment at https://github.com/amir20/dozzle/issues/2866#issuecomment-2054213811

So I think I prefer for it to be one or the other, but not both as introducing these toggles are complicated.

amir20 commented 1 month ago

Given all this, I don't think there is anything else.

cr0n76 commented 1 month ago

Then I realized you have dev.dozzle.group = paperless and not dev.dozzle.group=paperless. So I tried that and now I see:

Indeed! Did the trick for me as well. This mystery is solved!

When I checked swarm mode then it was as I remember (you can see it even in your picture for paperless): all logs are merged into one stream. Not what I want. Even though single containers are "grouped" there if labelled correctly.

I found the original bug that discussed the grouping logic. You can see the comment at https://github.com/amir20/dozzle/issues/2866#issuecomment-2054213811

So I think I prefer for it to be one or the other, but not both as introducing these toggles are complicated.

Hahaha! Thanks for the thread. I still have a different opinion, but you are right, you have discussed and decided this back then. I'm half a year late 😁