Skip to content

Add --all flag to docker container stop command #5930

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

Open
daviddl9 opened this issue Mar 14, 2025 · 5 comments
Open

Add --all flag to docker container stop command #5930

daviddl9 opened this issue Mar 14, 2025 · 5 comments

Comments

@daviddl9
Copy link

daviddl9 commented Mar 14, 2025

Problem Statement
Currently, stopping multiple containers requires explicitly listing them or using shell commands to pipe docker ps output. This creates friction for developers and operators who frequently need to stop all running containers during development or cleanup operations.

Proposed Solution
Add an --all flag to docker container stop that allows stopping all running containers in a single command. This aligns with existing Docker CLI patterns (e.g., docker container rm -a) and provides a more convenient workflow.

Benefits

  1. Improved developer experience by reducing command complexity
  2. Consistency with other Docker commands that support bulk operations
  3. Reduced risk of typos when manually listing container IDs
  4. Better automation support for cleanup scripts

Implementation Details

  • Add --all/-a flag to stop command options
  • When --all is specified, fetch all running containers and stop them
  • Maintain existing timeout and signal handling
  • Preserve current behavior when --all is not specified

Backwards Compatibility
This change is fully backwards compatible as it only adds a new optional flag.

Am happy to contribute if this enhancement request gets approved!

@daviddl9
Copy link
Author

just realised this is a duplicate of #1679, but that was created many years ago. Seems like it didn't get approved back then. Been finding myself doing docker stop $(docker ps -q) a lot (and on many different machines), seems like it might be a useful addition to add to the CLI. Would love to hear thoughts from the team on this!

@Benehiko
Copy link
Member

I agree that we need better commands to stop containers and do cleanups. It might be something we would consider implementing in the near future. I can't say if adding an --all flag is the solution here, it will require some thought and internal discussion among the maintainers.

@mdhaduk
Copy link

mdhaduk commented Apr 3, 2025

Hi, we're a group of students at UT Austin looking to contribute to virtualization-related open-source projects for our class. We came across this issue and would like to work on it if that's okay @Benehiko. Before we would proceed, we have some questions about the implementation since this is our first exposure to the Docker-cli codebase.

Currently, I'm just stating my interest in contributing but I will follow up within the next 2 days with our understanding of the issue and our potential implementation design.

Thanks.

@thaJeztah
Copy link
Member

@mdhaduk this feature request still needs discussion (as mentioned above), and probably isn't a "good first issue" for that reason.

This looks indded like a duplicate of;

But there's some other tickets with related discussion listed in;

@mdhaduk
Copy link

mdhaduk commented Apr 4, 2025

@thaJeztah I understand, thank you for clarifying that!

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

4 participants