Files
hackanooga.com/content/post/2024-04-03-stop-all-running-containers-with-docker.md
2025-02-19 16:36:29 -05:00

959 B

author, categories, date, guid, id, image, tags, title, url
author categories date guid id image tags title url
mikeconrad
Automation
Docker
Software Engineering
2024-04-03T09:12:41Z https://hackanooga.com/?p=557 557 /wp-content/uploads/2024/04/docker-logo-blue-min.png
Blog Post
Stop all running containers with Docker /stop-all-running-containers-with-docker/

These are some handy snippets I use on a regular basis when managing containers. I have one server in particular that can sometimes end up with 50 to 100 orphaned containers for various reasons. The easiest/quickest way to stop all of them is to do something like this:

docker container stop $(docker container ps -q)

Let me break this down in case you are not familiar with the syntax. Basically we are passing the output of docker container ps -q into docker container stop. This works because the stop command can take a list of container ids which is what we get when passing the -q flag to docker container ps.