How docker clears stopped containers

王林
Release: 2020-05-20 11:34:24
Original
3669 people have browsed it

How docker clears stopped containers

清除停止的容器有多种方法,如下:

方法一:显示所有的容器,过滤出Exited状态的容器,取出这些容器的ID,

sudo docker ps -a|grep Exited|awk '{print $1}'
Copy after login

查询所有的容器,过滤出Exited状态的容器,列出容器ID,删除这些容器

sudo docker rm `docker ps -a|grep Exited|awk '{print $1}'`
Copy after login

方法二:删除所有未运行的容器(已经运行的删除不了,未运行的就一起被删除了)

sudo docker rm $(sudo docker ps -a -q)
Copy after login

方法三:根据容器的状态,删除Exited状态的容器

sudo docker rm $(sudo docker ps -qf status=exited)
Copy after login

方法四:Docker 1.13版本以后,可以使用如下命令删除孤立的容器

sudo docker container prune
Copy after login

推荐教程:docker教程

The above is the detailed content of How docker clears stopped containers. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!