amir20 / dozzle

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

Docker Events in Web UI #3202

Closed sfc-gh-kbregula closed 3 weeks ago

sfc-gh-kbregula commented 1 month ago

Describe the feature you would like to see

Hey.

I'm part of a team that uses Doozle on a daily basis. Most of my team is non-technical, so accessing container logs via the Web UI is a big help.

We recently started modernizing our tech stack and started using Compose Develop/Compose Watch to automatically update and install dependencies as needed.

However, as the team is non-technical, we don't want long-lived processes in the terminal, so we run the docker-compose watch command as a separate container, which gives us detach mode. (Compose Watch doesn't support detach mode natively)

docker run --rm \
    --privileged \
    -d \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v "$(pwd):/$(pwd)" \
    -w "$(pwd)" \
    -e "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" \
    --name "compose-watcher" \
    docker:cli \
    sh -c '
      docker compose watch "${@}"
    ' "${ARGS[@]}"

But thanks to this we have access to the logs in Dozzle, so there is no problem for now.

The problem is that if we use Compose Develop, containers are restarted much more often and it is difficult to track when and which container was restarted.

I was wondering what you think about adding the ability to display Docker events in the Doozle UI. For now, we can use a container that runs a command similar to the one below.

curl --no-buffer --unix-socket /var/run/docker.sock -XGET "http:/v1.46/events" -s | jq .

But if it was a native feature of Doozle, it might look better and be more user-friendly.

Best regards,

Describe how you would like to see this feature implemented

No response

Describe any alternatives you've considered

No response

amir20 commented 1 month ago

I am not sure which events you are asking for. Isn't this already possible?

Screenshot 2024-08-13 at 2 22 23 PM

I only track stop and start. Did you have a different event in mind?

sfc-gh-kbregula commented 1 month ago

Compose Watch creates an entirely new container with the same name but a different ID, so Doozle does not display further logs in my case.

Screenshot 2024-08-13 at 23 30 14

I only have information that the container has been stopped; then, I have to select a new container from the side menu.

For my use case, an additional tab that contains information about when and which container was restarted would be ideal.

Something similar to the one below, but more refined, because I did it quickly in Bash.

Screenshot 2024-08-13 at 23 44 22
curl --no-buffer  --unix-socket /var/run/docker.sock -XGET "http:/v1.46/events" -s | jq "select(.Type == \"container\") | [.Type, .Action, .from] | @tsv" -r
amir20 commented 1 month ago

Hmm I don't know a lot about Compose Watch.

I think this would be a problem since all the logs are based off container ID. So if the ID is changing, then it is a new container to Dozzle. Dozzle tries to forward to the new container when this happens.

But in your case, I am not sure how to handle it since the events are actually on a different container. You can see this in the URL /container/ec727e499ea2.

The URL could be changed to name but that introduces other problems since names can clash between different servers.

If I understand correctly, you just want some other visualization that another container has started. Right? I don't know where that would go.

amir20 commented 1 month ago

@sfc-gh-kbregula re-reading this a bit now. It seems like you just want a way to show all events. Right?

Where do you think that could go? I don't think the section where all the logs go is the right place.

amir20 commented 3 weeks ago

Haven't heard back. Still not sure what is being asked. Closing.