Randomly-Generated Names are not as Helpful as they could be
Feature request description
Matching the behaviour of docker, if I don't specify an explicit name for a container, one is generated from an adjective and a (I think, scientist who probably didn't receive enough recognition in their time). This is a nice enough format, but it then makes it really hard to discern between active containers. I feel that a different scheme for generating default names would at least be no less descriptive and potentially could be quite a bit more.
I mostly use podman day-to-day for development containers. So I regularly pull things up with --rm -it, paste something in from the web, and don't give it a name for speed (or because I haven't really worked out what I need to do yet), try something out, and inevitably a few end up standing up for a little while. Or I get interrupted, have to jump over immediately to put out a different fire, and then can't wind which of the many terminals on eight desktops across five activities and two monitors was the magic one that contains what I was doing.
This may well be a me thing, but by contrast, I feel buildah's default of {ImageName}-working-container is quite a lot more helpful as a default. If I look at a container I immediately at least can narrow down what it was I was doing to a set of possibilities. I know podman ps does output the image name right next to it, but often my list overflows the terminal width, and it is a bit fiddly trying to match up the names to the images when they're now running over adjacent lines and I don't want to make a mistake and wipe out something I really still need. And the main thing being often this crops up not when running podman ps but when e.g. VS code is complaining for some reason about not being able to attach to a window, or maybe I see some dead/hanging process I need to kill - some situation where I have the container name in front of me, but not the image alongside it, and now need to go and run podman ps in a separate terminal, grep for it, get the image, go back to the original window, and then try to remember what I was possibly doing in that container.
After a while of using containers a lot, your mind easily confuses affectionate_curran with adoring_cohen and starts to tune them out a bit, and when I have lots of things on the go and suddenly need to perform an unexpected system restart and close everything off, I do quite often get lost, and on the odd occasion kill the wrong one once I've determined I don't need it anymore. So none of this is the end of the world, do;t mind if it's closed if it's literally just me an no-one else - but aside from the nice aesthetics, can't help but question if the default system really adds any helpful information, and if a different one might be able to and prove more useful in tracking a lot of ephemeral containers as they come and go. The image name would certainly help me narrow down/scan things a lot more easily, or the date when run and/or the startup command would be pretty good clues as to why I brought that one up; and at least more useful than a random one.
And yes, I know I probably should be giving it a name - I expect no-one here would say they haven't at least a few times pasted something long straight in from online docs and not spent some time waiting for the cursor to scan back to add a --name flag. I remember the days when people advised setting docker as an alias for podman after all ;). Also sometimes we're using other tools that create the containers for us and didn't think to name them.
Cheers
Suggest potential solution
Even if there were a unanimous decision to change from the current format to something else (which I doubt) I expect this might be a default behaviour people wouldn't want to break. So, some combination of image name, date, command are a few ideas that come to mind. But as I believe podman has good support for Go string templating in outputs, am wondering if it's a configuration option that can be tuned, and use some tmeplate that will be filled out if the user desires to set this option. Or conversely maybe that would be a lot of work to implement.
Have you considered any alternatives?
No response
Additional context
No response
I'm generally not in favor of this due to value in return; however, it is an interesting conversation. With {ImageName}-working-container how would you propose the next container on the same image be?
Personally I never understood why it uses auto generated names in the first place. It would have seemed much simpler to simply have no name and just use the ID instead. Of course podman copied this behavior from docker so overall I think changing the behavior now could be very disruptive. I can see why some would benifit from the image name, i.e. when you type podman rm and use tab completion it would give more meaning than totally random names.
But then also there is the case of --rootfs with uses a local path and images without names so this is not a universal fix either.
Overall I prefer to keep the current behavior.
Of course podman copied this behavior from docker so overall I think changing the behavior now could be very disruptive.
Probably could be considered with a major version bump if this is accepted. It is not breaking per se, but it will definitely be surprising for end users.
Just to add some context. This is how nerdctl handles naming - {imagename}-{id}, where {id} looks like some short hash, didn't check the sources.
% lima nerdctl run -d -p 127.0.0.1:8080:80 nginx:alpine
f51dd12f9639636d09d84bb30e7a64c610ee0147e3dd01d079c7f359ade07d2e
% lima nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f51dd12f9639 docker.io/library/nginx:alpine "/docker-entrypoint.…" 5 seconds ago Up 127.0.0.1:8080->80/tcp nginx-f51dd
% lima nerdctl run -d -p 127.0.0.1:8081:80 nginx:alpine
10afe0a3d8566659e283569e953263fc74316e8aad75299c2472fbd06223661f
% lima nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
10afe0a3d856 docker.io/library/nginx:alpine "/docker-entrypoint.…" 1 second ago Up 127.0.0.1:8081->80/tcp nginx-10afe
f51dd12f9639 docker.io/library/nginx:alpine "/docker-entrypoint.…" 18 seconds ago Up 127.0.0.1:8080->80/tcp nginx-f51dd
To not change the status quo, this could be considered as an additional feature - something like container-naming-strategy, where default is docker like, but one could change it in containers.conf
To not change the status quo, this could be considered as an additional feature - something like container-naming-strategy, where default is docker like, but one could change it in containers.conf
I am strongly against adding more complexity by using an option for this.
A friendly reminder that this issue had no activity for 30 days.
Personally I never understood why it uses auto generated names in the first place.
I think that's something I can keep in my memory for a short period of time. Guess open for debate but I can say if croc spat out a seven-character UID rather than a random token then I would stop using it as I won't remember it when walking from one room to the other.
Whether it's deemed worth changing or not, the nerdctl defaults seem quite a good compromise, that would resolve my personal situation. At some point I do mean to write a podman wrapper script and autogenerating a name fro mthe image ID would be easy enough. I have deferred on this simply due to the number of commands/arguments involved and the specific format they need to be in.