To stop all Docker containers simply run the following command in your terminal:
docker kill $(docker ps -q)
How It Works
- The docker ps command will list all running containers.
- The -q flag will only list the IDs for those containers.
- Once we have the list of all container IDs, we can simply run the docker kill command, passing all those IDs, and they’ll all be stopped!