Perhaps kill
is incorrect terminology, or I'm at least using it incorrectly.
How do I destroy docker containers? Put them in the trash. Delete. Remove. Erase.
docker container kill $(docker ps -a -q | awk '{print $1}')
doesn't quite work:
Error response from daemon: Cannot kill container: 06e44d24ba8d: Container 06e44d24ba8d3df83e10a1829f04755cb9053faa68ab3dabccd10c3ee1c80322 is not running
Error response from daemon: Cannot kill container: 22539a069e3b: Container 22539a069e3b8bbbd27b062603a7667857ac1a5e64242004fe7b72411a9cdbca is not running
Error response from daemon: Cannot kill container: 1f7cf43ab398: Container 1f7cf43ab398e6e18416f69fc947b49d9792b1932a4b157f0514f9f6638ca185 is not running
Error response from daemon: Cannot kill container: 7fc8c24ccabe: Container 7fc8c24ccabef04215df9ba7b8c171df6b963942e6e90c92a462cc0ab9d5dcb0 is not running
See also:
docker kill
will not destroy containers, it will just kill (stop) the running containers. Butdocker ps -a
will show also the non-running containers, so you get an error for all these non-running containers.Leave out the
-a
to kill only all running containers:Use
docker stop
instead ofdocker kill
if you want the processes to first try to terminate themselves (SIGTERM
) instead of killing directly (SIGKILL
).Or use
docker rm
to remove (destroy) containers:--force
or-f
is needed to also rm running containers.Note:
this will remove all containers.
Use
docker container prune
to remove all stopped containers.Please read the docs or run
docker help
to get more information about all the commands.