amir20 / dozzle

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

Unexpected grouping when using compose project and group labels #3069

Closed arjoonn-s closed 3 months ago

arjoonn-s commented 3 months ago

Is your feature request related to a problem? Please describe. I'm not sure if this is a feature / bug or just a generic question.

Describe the solution you'd like

I'm not sure what I'm doing wrong or if this can even be considered something in scope for dozzle?

PS: I love this project! I'm using v8.0.1

amir20 commented 3 months ago

Hmmm you should be seeing a Swarm Mode when you logs to be merged. This can happen with custom labels or swarm labels.

Let me test it to see if I broke something.

amir20 commented 3 months ago

It works on my side. I created two instance of a test container:

docker run -d --label dev.dozzle.group=test amir20/echo -r
docker run -d --label dev.dozzle.group=test amir20/echo -r

Then I see swarm mode. See video:

https://github.com/amir20/dozzle/assets/260667/167fcd6a-b04a-49b8-b9cd-14cb66f54b3c

I guess make sure docker inspect shows the proper labels? Not sure what else could be the problem.

amir20 commented 3 months ago

And holy cow 😂 32 CPUs. What monster are you running?

arjoonn-s commented 3 months ago

Hmm. I haven't tried swarm mode :thinking: . I'll give it a go in the morning tomorrow.

Meanwhile here's a small example of how to reproduce this. Maybe you can spot something here that I'm missing?

name: temp
networks:
  temp_net:
services:
  api:
    image: python:3.11
    command: 'python3 -m http.server'
    deploy:
      replicas: 3
    labels:
      - dev.dozzle.group=api
  agent:
    image: amir20/dozzle:latest
    command: agent
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - temp_net
  dozzle:
    image: amir20/dozzle:latest
    environment:
      - DOZZLE_REMOTE_AGENT=agent:7007
    ports:
      - 8989:8080 # Dozzle UI port
    networks:
      - temp_net
    depends_on:
      - agent

Running this using docker compose up results in the following screenshot where even though the api containers have the correct labels in docker inspect. Maybe I'm just expecting the wrong thing? I'm not sure since I've not needed to run docker in swarm mode before this.

"Labels": {
    "com.docker.compose.config-hash": "4cf98487dae71f1cdfaccd4ee0fd5e242b24b30ab503aa628ce670d34fd59d12",
    "com.docker.compose.container-number": "1",
    "com.docker.compose.depends_on": "",
    "com.docker.compose.image": "sha256:3794286e552da8e031aa8e986ea5f9765ca54bfd73f536905e93f72406d5c0d6",
    "com.docker.compose.oneoff": "False",
    "com.docker.compose.project": "temp",
    "com.docker.compose.project.config_files": "**********/temp/docker-compose.yml",
    "com.docker.compose.project.working_dir": "**********/temp",
    "com.docker.compose.replace": "89b17c2e2e0086321b0df901a177d83b7393f87407bc0988ab9c7e23bf3334d7",
    "com.docker.compose.service": "api",
    "com.docker.compose.version": "2.25.0",
    "dev.dozzle.group": "api"
}

image

PS: That previous machine is one of our prod on-prem servers . It's ironically named 'ant' :joy:

amir20 commented 3 months ago

I wish everybody would provide a yml file for me to reproduce. 🙏

Hmm. I haven't tried swarm mode 🤔 . I'll give it a go in the morning tomorrow.

There might be confusion here. Swarm mode in the UI has nothing to do with using swarm. It just merges the logs in to one stream when there is any kind of grouping, eg. services or custom groups.

I used your file and everything worked fine.

Screenshot 2024-07-06 at 12 22 23 PM

Again, note that swarm mode shows up automatically when the UI sees a grouping. For some reason it is not there for you.

I used docker compose -f bug-3069.yml up to bring it up.

So something is obviously different in your environment. Based on your screenshot I can't tell what it is.

I am not sure how to proceed? 😅

amir20 commented 3 months ago

On a side note, I might change the label for swarm mode to "services & groups" or something.

arjoonn-s commented 3 months ago

I found the issue. :facepalm: Docker cache had been using an old version of :latest. I pinned it to v8.0.1 and it worked like a charm :star:

image

Thank you so much for such a wonderful project!

amir20 commented 3 months ago

I thought that might be your problem but you said you are using latest. 😂