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

20 lines
868 B
Markdown

---
author: mikeconrad
categories:
- Automation
- Docker
- Software Engineering
date: "2024-04-03T09:12:41Z"
image: /wp-content/uploads/2024/04/docker-logo-blue-min.png
tags:
- Blog Post
title: 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.