lazydocker icon indicating copy to clipboard operation
lazydocker copied to clipboard

Feature request: show container names

Open mudasar187 opened this issue 6 years ago • 17 comments

Hi, i'v tested out lazydocker today and i love it! A feature to have is to have names on the containers where the Services window is.

I have a docker-compose.yml file:

version: '3.7'

services:
  mongodb:
    image: mongo
    container_name: "db_app"
    ports:
      - "27017:27017"

  frontend:
    image: quizgame/webclient
    container_name: "web_app"
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:3000"
    environment:
      - NODE_ENV=docker
    depends_on:
      - mongodb

In Services window, there is to running containers.

running frontend 0.00%
running mongodb 0.35%

It should be:

running frontend (web_app) 0.00%
running mongodb (db_app) 0.35%

Love this tool!

mudasar187 avatar Jul 01 '19 08:07 mudasar187

Sounds like a reasonable request. Given that there if often not much horizontal space, I'm inclined to make this a user configurable thing that defaults to false. Something like:

gui:
  showContainerName: true

What are your thoughts on that approach?

As for implementation, It would be fairly trivial to write the code, it would just be a matter of changing the GetDisplayStrings() function in pkg/commands/service.go. I'm happy to label this as Good First Issue and see if anybody wants to pick it up (I'm happy to lend a hand) :)

jesseduffield avatar Jul 01 '19 10:07 jesseduffield

Nice to hear :)

My thoughts is, make it default:

gui:
    showContainerName: true

And if someone dont want the container name then they can set it to false. If if there is no more space in horizontal then you can show like these examples:

running thisIsNameOfService (..) 0.00% (service name is long then add (..) to container name same on the other way.

And when you click on this service it will show a header on the left windows where Logs, Stats, Container Config, Top is and show the container name on the header.

mudasar187 avatar Jul 01 '19 10:07 mudasar187

My $0.02: I don't really want or need to see the container name in the sidebar (in the header of the main panel would be great though!) unless the service has a dynamic container_name. Knowing what directory lazydocker is running in would be more useful.

My primary use case is in development, where I run a few distinct projects that share service names. My services have static container names to make linking them together easier, and I'm never running a service as more than a single instance. If/when I cannot supply a container name (e.g. swarms), I'd still like to see the service listed, along with the specific containers.

pvande avatar Jul 01 '19 16:07 pvande

@pvande how about instead of having lazydocker in the status panel in the top left, we have the name of the current directory?

As for dynamic container names, I wonder how easy it is to see if a container name is dynamic.

@mudasar187 I'm hesitant to use the ellipsis approach because it seems to me that people either want to know what the container name is or not, and if they have no way to expand the width of the side panels, they can't really access that information. This makes me think we should probably support having a short and long sidepanel view for when you want everything you need in tabular form, but that's a separate issue.

If we could find a way to check if a container name was dynamic, and if so, show it in brackets, would that satisfy both your use cases?

jesseduffield avatar Jul 02 '19 10:07 jesseduffield

@jesseduffield Yeah, i think thats a better suggestion :)

mudasar187 avatar Jul 02 '19 10:07 mudasar187

@jesseduffield I would have suggested putting it in that status panel, but I didn't want to suggest losing the branding!

As for dynamic container names, I'm more or less working from the definition "the docker-compose service does not specify a container_name key". That may not be perfectly adequate, but it seems like a good starting point.

pvande avatar Jul 02 '19 20:07 pvande

Given that Container names may be long, and Services may have multiple containers associated with them, I'm increasingly inclined towards a UI like this:

image

I would be curious to hear what other people think of this, and how other people would expect it to work. If there's enough interest in this approach, I may go ahead and try to move it forward myself...

pvande avatar Jul 27 '19 18:07 pvande

Happy to have a look into this over christmas break if that's ok

punk-dev-robot avatar Dec 19 '19 13:12 punk-dev-robot

Please, go ahead.

dawidd6 avatar Dec 19 '19 14:12 dawidd6

Hi, is anyone working on it, otherwise I would like to pick this up

mihirsn avatar Aug 14 '20 19:08 mihirsn

I belive we can close this right? now days we show the container name

image

loopsFreitag avatar Oct 24 '24 15:10 loopsFreitag

@loopsFreitag It does seem container names are shown in the general case, but not all. In some cases, I see ubi8 and I don't know where it comes from, although this discussion thread https://github.com/jesseduffield/lazydocker/discussions/524 suggests it comes from the label block, which I don't see.

huyz avatar Dec 18 '24 14:12 huyz

@huyz Yes, that is true, today we prioratize taking this information from the container labels, i made a small PR to change this behavior https://github.com/jesseduffield/lazydocker/pull/625

loopsFreitag avatar Feb 03 '25 16:02 loopsFreitag

@loopsFreitag great, thanks!

huyz avatar Feb 03 '25 16:02 huyz

Hi, why is the PR for this issue not merged yet? I run into this same issue and it would be great to see the container name instead of the Labels.Name field.

pasquale95 avatar Oct 20 '25 18:10 pasquale95

Seems like this repo is no longer maintained. Since it's not getting updates regularly. @jesseduffield

Maybe you can use a custom build

loopsFreitag avatar Oct 20 '25 18:10 loopsFreitag

what, lazydocker development getting lazy? 😬

huyz avatar Oct 22 '25 07:10 huyz