Managing a docker infrastructure with many containers can be tedious at times.
Docker containers can be stopped like this:
docker stop MY_CONTAINER_NAME_OR_ID
Using “docker ps” to see running containers, one can stop all containers one by one using the container name or id.
This takes our valuable time away and since Linux is the best OS out there for productivity, a simple solution is this:
docker stop $(docker ps -q)
This stops all containers with id’s that are dumped by using the command “docker ps -q” to just print the ids of running containers.
Off course removing containers can be achieved using this principle as well:
docker rm $(docker ps -aq)