在日常工作中,我们经常会遇到很多状态为Exited 的docker容器,想要清除它,可以用如下命令清除。
lwk@harbin:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
17a8f44ebefa redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago musing_burnell
a2095cbd949f redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago jovial_ardinghelli
0556f033d5a5 redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago jovial_wozniak
389a16a772b8 redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago goofy_satoshi
fc806f58965d redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago laughing_jang
8fdf5fa276bf redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago naughty_wilson
26019aec0c79 redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago quirky_davinci
39131bd66c3f redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago exciting_shaw
ae9df6bdb06f redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago compassionate_hugle
848c6584d09c redis:6.2.6-alpine "redis-cli -h 172.81…" 2 weeks ago Exited (0) 2 weeks ago charming_spence
45e0caa8dcfc redis:6.2.6-alpine "redis-server --appe…" 2 weeks ago Up 41 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
lwk@harbin:~$ docker rm $(docker ps --filter status=exited -q)
17a8f44ebefa
a2095cbd949f
0556f033d5a5
389a16a772b8
fc806f58965d
8fdf5fa276bf
26019aec0c79
39131bd66c3f
ae9df6bdb06f
848c6584d09c
lwk@harbin:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45e0caa8dcfc redis:6.2.6-alpine "redis-server --appe…" 2 weeks ago Up 48 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
lwk@harbin:~$
|