-
-
Save evanscottgray/8571828 to your computer and use it in GitHub Desktop.
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt |
docker rm -f $(docker ps -f name=IMAGE_NAME -q) || true
rm -f
stops and removes the containers- when nothing is running the rm fails
so using this:
docker rm -f $(docker ps -aq) >/dev/null 2>&1 || true
On macOS this is my way to go (adapted from @timka):
docker ps -q | xargs docker stop ; docker system prune -a
@coolavibv that was smooth ... dang github needs a tangent thread like reddit now .. cheers
remove all containers forcefully
docker rm -f $(docker ps -a -q)
remove all docker images forcefully
docker rmi -f $(docker images -q)
@gdevdeiv This work for me!!! Tks!
good- very helpful.
cool
thanks @gdevdeiv this was a lifesaver: https://gist.github.com/evanscottgray/8571828#gistcomment-2594902
Thanks @gdevdeiv...
docker dance $(docker ps -q)
#stop all containers:
docker stop $(docker ps -a -q)
#stop all containers by force
docker kill $(docker ps -q)
#remove all containers
docker rm $(docker ps -a -q)
#remove all docker images
docker rmi $(docker images -q)
#purge the rest
docker system prune --all --force --volumes
Thanks!
docker kill [ID]
To get the ID of the running container, run:
docker ps
example:
docker kill b0e6f105b024
@francolaiuppa lol bash fu
Thanks, helped.
Thank you all
@evanscottgray that's a terrible way to do it. As others have pointed out, do not do this, but:
docker kill $(docker ps -q)
why is there not simply a docker container stop --all or something similar for windows? Sorry if this question has already been answered
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)
docker rm -f $(docker ps -a -q)
@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
.
docker container stop $(docker container ls -q)
thanks, worked like a charm !!
All didn't work for me
I used docker stop $(docker ps -a -q)
All did n't work for me
I used
docker stop $(docker ps -a -q)
docker kill, not stop
doing it like this:
https://gist.github.com/digitalist/abf3320fa5ad937015cca15920e25acc
sudo docker kill $(sudo docker ps -q)
Why not something like docker stopall
?
docker kill $(sudo docker ps -q)
This is great, thanks @webdev23 !
Note: only not running containers. So you might want to shut all containers down first.