gpt4 book ai didi

docker - 如何快速删除许多正在运行的容器?

转载 作者:行者123 更新时间:2023-12-02 20:53:20 26 4
gpt4 key购买 nike

这是我的 Docker 版本
enter image description here

C:\Users\MyPC>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
afa475802276 79da37e5a3aa "/kube-vpnkit-forwar…" 2 minutes ago Up 2 minutes k8s_vpnkit-controller_vpnkit-controller_kube-system_9540df34-3843-404b-9c49-2926ddc90936_8
d78a7306634a 6f7135fb47e0 "kube-scheduler --au…" 3 minutes ago Up 3 minutes k8s_kube-scheduler_kube-scheduler-docker-desktop_kube-system_c808ba8a724ff4e00643b5c4f7fc454b_2
c978ce115c2b 303ce5db0e90 "etcd --advertise-cl…" 3 minutes ago Up 3 minutes k8s_etcd_etcd-docker-desktop_kube-system_d6844c5fb9714fb5465ba8579918e27e_7
2292aca10b10 k8s.gcr.io/pause:3.2 "/pause" 3 minutes ago Up 3 minutes k8s_POD_etcd-docker-desktop_kube-system_d6844c5fb9714fb5465ba8579918e27e_0
ae0d69730332 k8s.gcr.io/pause:3.2 "/pause" 3 minutes ago Up 3 minutes k8s_POD_vpnkit-controller_kube-system_9540df34-3843-404b-9c49-2926ddc90936_0
7bbe7c5f5b47 k8s.gcr.io/pause:3.2 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-scheduler-docker-desktop_kube-system_c808ba8a724ff4e00643b5c4f7fc454b_0
dc4b52d7599d 6a979351fe5e "kube-controller-man…" 6 minutes ago Up 6 minutes k8s_kube-controller-manager_kube-controller-manager-docker-desktop_kube-system_4f20c2277b1a9bc95a8d0aefdd70ac22_6
7d0f3d7156ef 0fb7201f92d0 "/usr/local/bin/kube…" 7 minutes ago Up 7 minutes k8s_kube-proxy_kube-proxy-2b8sn_kube-system_3ae7b44b-efc4-4943-9e1d-8b8147b8326c_1
bddc4c169ded k8s.gcr.io/pause:3.2 "/pause" 7 minutes ago Up 7 minutes k8s_POD_kube-proxy-2b8sn_kube-system_3ae7b44b-efc4-4943-9e1d-8b8147b8326c_0
e5c889b04bc4 k8s.gcr.io/pause:3.2 "/pause" 8 minutes ago Up 8 minutes k8s_POD_kube-controller-manager-docker-desktop_kube-system_4f20c2277b1a9bc95a8d0aefdd70ac22_0
73e4df185c0f 92d040a0dca7 "kube-apiserver --ad…" 8 minutes ago Up 8 minutes k8s_kube-apiserver_kube-apiserver-docker-desktop_kube-system_04dc74f076b53c39b47cb1bf82330dfd_5
5ceb2bb7854a k8s.gcr.io/pause:3.2 "/pause" 8 minutes ago Up 8 minutes k8s_POD_kube-apiserver-docker-desktop_kube-system_04dc74f076b53c39b47cb1bf82330dfd_0
e4ef2ead5178 67da37a9a360 "/coredns -conf /etc…" 8 minutes ago Up 8 minutes k8s_coredns_coredns-66bff467f8-kg6kr_kube-system_eba4da7c-5032-44ef-9459-8701a09d1563_6
8ddab551bdea k8s.gcr.io/pause:3.2 "/pause" 8 minutes ago Up 8 minutes k8s_POD_coredns-66bff467f8-kg6kr_kube-system_eba4da7c-5032-44ef-9459-8701a09d1563_0
d210bfec7f44 e704287ce753 "/storage-provisione…" 12 minutes ago Up 12 minutes k8s_storage-provisioner_storage-provisioner_kube-system_b694d184-63f0-4201-917b-8d374bf28017_8
8b2685514ed0 k8s.gcr.io/pause:3.2 "/pause" 12 minutes ago Up 12 minutes k8s_POD_storage-provisioner_kube-system_b694d184-63f0-4201-917b-8d374bf28017_0
6c129599fd6b 67da37a9a360 "/coredns -conf /etc…" 13 minutes ago Up 13 minutes k8s_coredns_coredns-66bff467f8-9mpnd_kube-system_96b97b40-5fa6-49e3-b94f-f4ec4f217d45_5
c42a316116ab k8s.gcr.io/pause:3.2 "/pause" 13 minutes ago Up 13 minutes k8s_POD_coredns-66bff467f8-9mpnd_kube-system_96b97b40-5fa6-49e3-b94f-f4ec4f217d45_0
03c9d71f6c04 kong "/docker-entrypoint.…" 5 months ago Restarting (1) 48 seconds ago kong-compose_kong-server_1

C:\Users\MyPC>
我不能这样删除
enter image description here
enter image description here
如何快速删除许多正在运行的容器?
enter image description here
无法停止,无法删除
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> docker ps -q | % { docker stop $_ }
98148a7fea66
22ce3305e38b
eaf38765da00
3b0129950011
6bdffc6db010
106decb1be35
61f339dd02eb
b02ccac54b6d
4ce11b2ea3a1
2ecdce35ab73
a9edf6b0d2c1
9b626a90dd60
211636cfbfe7
c860e5da7c48
76ddb3fd8cc3
e40b6dce8f1a
59bc53d2c241
b000e4f46859
PS C:\Windows\system32> docker rm $(docker ps -a -q)
9843ef5f0770
c5a0cee3c389
39628bf22d7c
b8128b5641f7
4bea9e14d82f
03c9d71f6c04
9ace41309174
Error response from daemon: You cannot remove a running container 1bdf777c9092ef7895edbfe54bacc0a4ddc98e9eaea70b95e2dbc99b15b0a372. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container f8265c1c475d8d5ef39db6c8704d9fe6c4543374ea24a0c44061b9aacf9c7cc8. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container ed36537ac28193703e087e2961da44131cb4600625cd0047b81a4e36dbf9f258. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container f7075e59456bb938edd8ec01d79a1db963f54de555f3eac30244d3f91c994150. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 2dbb2ddd933742b5c78b5a851bfdff7fe7fa01bc185fa0095332e541cbce04b1. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 1a48a31da3b2377614bb15e9e278956f4cc34142b939c0f224cf4b4cd649d25a. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container e094553f95890485566c3210f1dc46568127949edf634f36a2ddee0c623cfc2f. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 6cb9fc76ab8a8eea3111b04ee4d078d5dbd3ac25fa62a441b4cc7883e48c99d6. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container d15ab01f6cfe6d1e1a77407508670f0e1b2a24817ac941bf28f053e58372d5c1. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container a2042660aa1a8741be475a157b41ec5c514e07053bc62921bd7a13b67818380d. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 41f8d47cf4499ad809381c7f9903cf09abdf5a60942d60c493f1e0b7016c5229. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 6a7e5fc20ebb6be8758ccbfdff82d99d2bb2adc882327b1fb2f3f33ed4fa919d. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 8243bf76aebf5a7b6c0ca135c763d00f247ac533ffe16cf82c9ce9c20d70d420. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 7c48bbed98a41686999d7f7e9abbfb1d33c0d7f5b5c78fd85e5210c3271e1fdf. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 66c0a63ff3cbb3d1fb01744a308b9cef555b02debd7be9182f3e34b0d13cfa31. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container c72c5806c873d384f1b86b13c3e3183db287a82deddef9652f8989e367478524. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 8a831b51b4e2846ddb02d7a0f74c120751765b54eda37fc8248417add74b5493. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 7d7e2d4a01b5f7b4922dbb0dd5d4d6c9a03ffbbee4237657ead953b32f3d4c48. Stop the container before attempting removal or force remove
PS C:\Windows\system32> docker stop $(docker ps -aq)
1bdf777c9092
f8265c1c475d
ed36537ac281
f7075e59456b
2dbb2ddd9337
1a48a31da3b2
e094553f9589
6cb9fc76ab8a
d15ab01f6cfe
a2042660aa1a
41f8d47cf449
6a7e5fc20ebb
8243bf76aebf
7c48bbed98a4
66c0a63ff3cb
c72c5806c873
8a831b51b4e2
7d7e2d4a01b5
PS C:\Windows\system32> docker rm $(docker ps -a -q)
Error response from daemon: You cannot remove a running container 42fd8f395ca14f0b79675231d7d75b9783a9ecf3b66b7726a8602064b108a491. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 878656e6850948e6cd9d64db4087f74bed5a9f4165214eb33e64104d27493071. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container e04311cbf62cdb6a09327c25ca9a1f67c16217e0887f75ae7c5811000e4600d0. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 402e94cbdc0366b47fd31f16e5de5d65aff8075ce7a1551465e072eca95c1b14. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container d1fbca7afc925cb7adc73bea9911c0cc132a3e0cf60ef78daf8021c89a3bf172. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container fd5d0fc32f15804ae15332458b4d02e10c633fd90a34ae909cbbbb44a7d59332. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 2368bb5e18148511848e8647244ee7c34b7af6d78b05f6b523d57c4f06726ca7. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 0be629337f759610569a3d4e580e213410a4e1710870bf3509048fb6e4f6ae8f. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 82acd141a39492f267f30484f5d2d6cb640afceddd06aa31bbe28e2445712cec. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container d158778aa105ecbc49aeb32662252d5448da50ab4b516cac5a2a47888e723f77. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 04b02e1c5101f20a782cfd60cd0c7b8f2fcfb1584bce39d9b9660495c0f5ebe9. Stop the container before attempting removal or force remove
PS C:\Windows\system32>
PS C:\Windows\system32> docker stop $(docker ps -a -q)
42fd8f395ca1
878656e68509
e04311cbf62c
402e94cbdc03
d1fbca7afc92
fd5d0fc32f15
2368bb5e1814
0be629337f75
82acd141a394
d158778aa105
04b02e1c5101
PS C:\Windows\system32> docker rm $(docker ps -a -q)
Error response from daemon: You cannot remove a running container f0f8e84bb179dc5843e626a7b1962c0f3a344b34eb1f699e7baa7fc2767fa9be. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 5a02475207b2259ddbca4487c27092ca62b8c68cb651e486a48011bd1e077048. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container f0ea82fee5f881a0f9b433e6788cfbf8bd51546e8a24ca8134170430b850845a. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 874c985774bcd0f4063334a20c255294681832c417db045b63ef8c6516e93bcb. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container e4a52f0894f39ee709b49993bc96a18ce029fc1541759f4a56accfc55a1aebef. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 9f3d2015a2b8cbc2dc8e72256d535de7b1d8edd2574e412e5ade204e2eb2009f. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container 727afd9c0c2efe61de747f8d27d5f8e8dee015a87af2b9251de72012ba328a49. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container a13b4da1838be47425e8e7a4c38e206651f9722e9f1372c3f2dd94af6c33ae0c. Stop the container before attempting removal or force remove
Error response from daemon: You cannot remove a running container a0e2ce0b1c9aa222d943bff0de1c62930a226c7ca28a8e09e40131bbc79a96c2. Stop the container before attempting removal or force remove
PS C:\Windows\system32>

最佳答案

您最好的选择是docker system prune删除所有停止的容器、未使用的网络和悬空图像。docker system prune -a还将删除与运行无关的任何图像
容器。docker system prune -a --volumes还将删除非事件卷。

关于docker - 如何快速删除许多正在运行的容器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64310928/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com