docker / docker/cli

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

Open
#5,455 3 comments 0 reactions 1 assignee View on GitHub

@laurazard is already working on this.

Since Sep 20, 2024.

kind/enhancement kind/feature
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.