docker / cli

The Docker CLI
Apache License 2.0
4.94k stars 1.93k forks source link

Add Indicator in `docker ps` for Containers Created with docker-compose #5455

Open kha84 opened 1 month ago

kha84 commented 1 month ago

Description

It would be incredibly helpful if docker ps could include a built-in indicator showing whether a container was created using docker-compose or docker run directly, without requiring additional commands or manual inspection.

Problem

Currently, there is no straightforward way to immediately tell from docker ps whether a container was created with docker-compose. Users have to:

This extra step makes managing large sets of containers cumbersome, especially when both docker-compose and docker run are used in parallel within a project or environment.

Proposed Solution

Add an indicator in the output of docker ps to differentiate containers based on their creation method. For example, this could include:

Example output

CONTAINER ID   IMAGE       COMMAND      CREATED       STATUS       PORTS    CREATED BY        NAMES
abc123         nginx       "nginx -g…"  10 hours ago  Up 5 hours   ...      docker-compose    myapp_web_1
def456         redis       "redis-server" 5 hours ago Up 3 hours   ...      docker run        redis-container

Benefits

  1. Improved Clarity: Users can immediately tell which containers were created with docker-compose and which are standalone without needing to inspect each container manually.
  2. Better Management: It would make it easier to manage containers in mixed environments, especially when troubleshooting or cleaning up containers.
  3. Saves Time: This would eliminate extra steps like running docker inspect or setting up custom naming schemes to differentiate container origins.

Considerations

Closing Thoughts

This feature would significantly enhance usability, especially for users who work with both docker-compose and docker run. It would improve container management and make the docker ps command more informative and user-friendly.

laurazard commented 1 month ago

Hi @kha84, thanks for the contribution!

I definitely agree, and we've actually been discussing improvements internally to things such as the image list and other commands, particularly regarding integrations with plugins (such as your Compose suggestion) – ideally, IMO, since Compose is the plugin that know about the annotations it sets, Compose could enhance the container list output for these containers.

We have to have some discussion in terms of how to implement this, but IMO this is something we'd like to do, just need to figure out how/do it.

I'll share internally as well :).