How to Stop Running and Unresponsive Docker Containers | Warp
Introducing Warp Factories: open, flexible infrastructure for building your own cloud software factory. Learn More
The short answer
In Docker, to stop all the running containers at once, you can combined the docker stop and docker ps commands as follows:
Bash
$ docker stop $(docker ps -q)
Where:
- The $() syntax is used to execute a shell command in a subshell.
- docker ps -q is used to output the IDs of all running Docker containers.
Stopping unresponsive containers
To stop unresponsive containers, you can use the docker kill command, which will send a SIGKILL signal to all the processes inside of the container and instantly terminate the container itself:
Bash
$ docker kill <container …>
Where:
- container ... is a list of container IDs or names.
Alternatively, you can use the following command to forcefully stop all containers:
Bash
$ docker kill $(docker ps -q)
For example:
Bash
$ docker kill 641710a3ab3a test-psql-db
Easily retrieve these commands using Warp's AI Command Suggestions feature
If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:
Entering docker stop all containers in the AI Command Suggestions will prompt a docker command that can then quickly be inserted into your shell by doing CMD+ENTER.