Add Indicator in `docker ps` for Containers Created with docker-compose
@laurazard is already working on this.
Since Sep 20, 2024.
- 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 inspectto check for thecom.docker.composelabels.
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
- Improved Clarity: Users can immediately tell which containers were created with
docker-composeand which are standalone without needing to inspect each container manually. - Better Management: It would make it easier to manage containers in mixed environments, especially when troubleshooting or cleaning up containers.
- Saves Time: This would eliminate extra steps like running
docker inspector 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.