Skip to content

Instantly share code, notes, and snippets.

@evanscottgray
Last active November 7, 2023 03:40
Show Gist options
  • Save evanscottgray/8571828 to your computer and use it in GitHub Desktop.
Save evanscottgray/8571828 to your computer and use it in GitHub Desktop.
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
@da7a90
Copy link

da7a90 commented Sep 25, 2019

@francolaiuppa lol bash fu

@labohkip81
Copy link

Thanks, helped.

@AndersonChoi
Copy link

Thank you all

@eenchev
Copy link

eenchev commented Dec 4, 2019

@evanscottgray that's a terrible way to do it. As others have pointed out, do not do this, but:
docker kill $(docker ps -q)

@IOnlyFetchBranches
Copy link

IOnlyFetchBranches commented Dec 12, 2019

why is there not simply a docker container stop --all or something similar for windows? Sorry if this question has already been answered

@ddelrio1986
Copy link

If you want to be a hipster and stop all running containers using the management commands than use this.

docker container stop $(docker container ls -q)

@adeelibr
Copy link

docker rm -f $(docker ps -a -q)

@evanscottgray
Copy link
Author

@eenchev completely agree. When I wrote this like six years ago, I had no idea what I was doing. 😅

...and some would argue that not much has changed!

These days I use something closer to docker ps -qa | xargs docker stop.

@umar-muneer
Copy link

docker container stop $(docker container ls -q)

thanks, worked like a charm !!

@veritem
Copy link

veritem commented Dec 3, 2020

All didn't work for me

I used docker stop $(docker ps -a -q)

@chrisharrisonkiwi
Copy link

All did n't work for me

I used docker stop $(docker ps -a -q)

docker kill, not stop

@digitalist
Copy link

@webdev23
Copy link

sudo docker kill $(sudo docker ps -q)

@sorenwacker
Copy link

Why not something like docker stopall ?

@mjrdnk
Copy link

mjrdnk commented Oct 17, 2022

docker kill $(sudo docker ps -q)

This is great, thanks @webdev23 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment