HariSekhon / Dockerfiles

50+ DockerHub public images for Docker & Kubernetes - DevOps, CI/CD, GitHub Actions, CircleCI, Jenkins, TeamCity, Alpine, CentOS, Debian, Fedora, Ubuntu, Hadoop, Kafka, ZooKeeper, HBase, Cassandra, Solr, SolrCloud, Presto, Apache Drill, Nifi, Spark, Consul, Riak
https://www.linkedin.com/in/HariSekhon
MIT License
1.32k stars 466 forks source link

how can delete all docker containers not used? #57

Open johnfelipe opened 2 years ago

johnfelipe commented 2 years ago
docker rm bb2afb1ec924
docker rm 26b7e3c4e010
docker rm 6932e19f8031
docker rm fb72d73d1675
docker rm 9a658133ced9

this not good workflow each time for review cassandra avaible or not have a contanier

root@ubuntu20dockers:~/Dockerfiles/nagios-plugins-cassandra# docker ps -a
CONTAINER ID   IMAGE                                 COMMAND                  CREATED             STATUS                         PORTS     NAMES
26b7e3c4e010   harisekhon/nagios-plugins             "find_active_cassand…"   33 seconds ago      Exited (1) 31 seconds ago                beautiful_fermat
6932e19f8031   harisekhon/nagios-plugins             "find_active_cassand…"   2 minutes ago       Exited (3) 2 minutes ago                 quizzical_nightingale
fb72d73d1675   harisekhon/nagios-plugins             "find_active_cassand…"   4 minutes ago       Exited (3) 4 minutes ago                 blissful_perlman
bb2afb1ec924   harisekhon/nagios-plugins             "find_active_cassand…"   4 minutes ago       Exited (0) 4 minutes ago                 sleepy_darwin
9a658133ced9   harisekhon/nagios-plugins             "find_active_cassand…"   10 minutes ago      Exited (3) 10 minutes ago                suspicious_stonebraker
a623dd501d39   harisekhon/nagios-plugins             "check_zaloni_bedroc…"   29 minutes ago      Exited (3) 29 minutes ago                musing_neumann
566ce41b26e3   harisekhon/nagios-plugins:cassandra   "check_zaloni_bedroc…"   31 minutes ago      Exited (4) 31 minutes ago                pedantic_maxwell
812501ccb4b3   harisekhon/nagios-plugins:cassandra   "check_zaloni_bedroc…"   38 minutes ago      Exited (4) 38 minutes ago                wonderful_kepler
d5de82e52415   harisekhon/nagios-plugins:cassandra   "/bin/bash -c 'find …"   43 minutes ago      Exited (0) 43 minutes ago                vigorous_kalam
2d98bcbfeec7   harisekhon/cassandra-dev:latest       "/bin/sh -c /entrypo…"   46 minutes ago      Exited (137) 35 seconds ago              cassandra-dev_cassandra_1
86d472f28229   harisekhon/nagios-plugins             "check_ssl_cert.pl -V"   47 minutes ago      Exited (3) 47 minutes ago                compassionate_chatelet
69f03cedcf49   harisekhon/nagios-plugins             "check_ssl_cert.pl -…"   49 minutes ago      Exited (3) 49 minutes ago                interesting_jackson
878cb6c2a5a8   harisekhon/nagios-plugins             "/list_plugins.sh"       49 minutes ago      Exited (0) 49 minutes ago                sleepy_burnell
a66982209491   harisekhon/pytools                    "dockerhub_search.py…"   49 minutes ago      Exited (4) 49 minutes ago                peaceful_galois
50571f96794a   jasonrivers/nagios:latest             "/usr/local/bin/star…"   About an hour ago   Exited (4) About an hour ago             nagios4

for delete container

root@ubuntu20dockers:~/Dockerfiles/nagios-plugins-cassandra# docker rm 26b7e3c4e010
26b7e3c4e010
root@ubuntu20dockers:~/Dockerfiles/nagios-plugins-cassandra# docker rm 6932e19f8031
6932e19f8031
root@ubuntu20dockers:~/Dockerfiles/nagios-plugins-cassandra# docker rm fb72d73d1675
fb72d73d1675
root@ubuntu20dockers:~/Dockerfiles/nagios-plugins-cassandra# docker rm 9a658133ced9
9a658133ced9
devarsh10 commented 1 year ago

Hey @johnfelipe, You can delete all unused containers from Docker Desktop[Software]. Instead of using docker rm {id_1} {id_2}....

Regards.

HariSekhon commented 1 year ago

docker rm -f -- $(docker ps -a --format "{{.ID}}")