Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kha84 opened this issue Sep 19, 2024 · 1 comment
Open

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

kha84 opened this issue Sep 19, 2024 · 1 comment

Comments

@kha84
Copy link

kha84 commented Sep 19, 2024

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:

  • Rely on naming conventions (which can be customized and aren’t always reliable).
  • Run docker inspect to check for the com.docker.compose labels.

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:

  • A new column (or a flag option to enable this column) that indicates Created by (docker-compose, docker run, etc.).
  • For containers created with docker-compose, also show the Compose project name and service name as additional columns (e.g., PROJECT/SERVICE).

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

  • This feature could be enabled by default or as an optional flag (e.g., docker ps --show-origin), depending on how cluttered the output might get in different scenarios.
  • Compatibility with containers created by other orchestration tools could also be considered.

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
Copy link
Member

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 :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants