在使用了docker一段时间后,会发现系统上各种容器乱七八糟,启动的,未启动的,正常运行的,异常的,搞得人不胜其烦。
下面是一次完全删除docker容器并删除docker本身的实例,可以完美解决以上问题。
查询并停止/删除当前运行容器 ➜ ~ docker ps -aq 80bb62721c12 # 停止当前运行容器 ➜ ~ docker stop $(docker ps -aq) 80bb62721c12 # 删除当前运行容器 ➜ ~ docker rm $(docker ps -aq) 80bb62721c12 删除所有image镜像 ➜ ~ docker rmi $(docker images -q) Untagged: traffmonetizer/cli_v2:latest Untagged: traffmonetizer/cli_v2@sha256:4fc48893746664471a1c386efabb5eba0537955fe5ecae871ed4a5e5c33ecf03 Deleted: sha256:3f82fd6f8f4f5ae49cf715a45db4abb3c0bef25be4d351ebe82e747f8641dd0b Deleted: sha256:d732b5c154d947acd46254d7c729eea712f5dd3e0518884a50cc4ada4da9706d Deleted: sha256:037fbfa145577a9bc6472afdf57979ff128102d42806eebc4dcdbc7eb0c91ff5 Deleted: sha256:e44bc785a3f33dea2990cff187bc1c2b7fea4fa9dfa24a6c3ad3e4c149e7aa80 Deleted: sha256:aa0a4b16279d7f4e301aa29ff8bb3fb2e5eaf2417e8119bd3c92f99da975d674 Deleted: sha256:54d0ead5d2a5dd2e830b333508445bc7e9cbed60b1ec4091d667c71349a9b31c Deleted: sha256:bd00ba4d604e3a30bba51756da10622d2242a8540dc03a46a07584575d736590 Deleted: sha256:d4fc045c9e3a848011de66f34b81f052d4f2c15a17bb196d637e526349601820 卸载docker ➜ ~ apt purge docker-ce Reading package lists... Done Building dependency tree... Done Reading state information... Done The following package was automatically installed and is no longer required: pigz Use 'apt autoremove' to remove it. The following packages will be REMOVED: docker-ce* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 109 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64321 files and directories currently installed.) Removing docker-ce (5:27.2.0-1~debian.12~bookworm) ... (Reading database ... 64312 files and directories currently installed.) Purging configuration files for docker-ce (5:27.2.0-1~debian.12~bookworm) ... ➜ ~ apt purge docker-ce-cli Reading package lists... Done Building dependency tree... Done Reading state information... Done The following package was automatically installed and is no longer required: pigz Use 'apt autoremove' to remove it. The following packages will be REMOVED: docker-ce-cli* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 40.9 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64310 files and directories currently installed.) Removing docker-ce-cli (5:27.2.0-1~debian.12~bookworm) ... Processing triggers for man-db (2.11.2-2) ... ➜ ~ apt purge docker-ce-rootless-extras docker-buildx-plugin Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: libslirp0 pigz slirp4netns Use 'apt autoremove' to remove them. The following packages will be REMOVED: docker-buildx-plugin* docker-ce-rootless-extras* 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. After this operation, 102 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64111 files and directories currently installed.) Removing docker-buildx-plugin (0.16.2-1~debian.12~bookworm) ... Removing docker-ce-rootless-extras (5:27.2.0-1~debian.12~bookworm) ... ➜ ~ apt purge docker-compose-plugin Reading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: libslirp0 pigz slirp4netns Use 'apt autoremove' to remove them. The following packages will be REMOVED: docker-compose-plugin* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 63.3 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 64102 files and directories currently installed.) Removing docker-compose-plugin (2.29.2-1~debian.12~bookworm) ...