by Devin Yang

建立于: 8年前 ( 更新: 8年前 )

有时在自己的环境中试了一堆container或是images,如何全部移掉系统中所有的images及container 呢?
这些命令提供给大家参考: 

请注意,您确实了解docker中container及images是什么东西。
请勿随意运行如下的命令,在上线中的主机上:


stop all containers: 停止所有的container

docker kill $(docker ps -q)

remove all containers: 移除所有的container
docker rm $(docker ps -qa)

remove all docker images: 移除所有的docker images
docker rmi $(docker images -q)


注: 关於docker stop及docker kill差异,我们可透过如下命令查看说明:
docker help stop
The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL.

docker help kill
The main process inside the container will be sent SIGKILL, or any signal specified with option --signal.

Tags: docker

Devin Yang

文章内容无法一一说明,如果您有什么不了解处,欢印提问哦:)

No Comment

Post your comment

需要登入才可留言!

类似文章


docker

Devin Yang的Docker初学笔记

这是我初学Docker时的笔记,有点粗糙,有调整了一下下。 但我想对於Docker初学者,应该可以提供一些初步的概念, 欢迎参考看看。

docker,php,cli

MacOS的php不给力,用docker运行laravel installer

非常简单呀,加个「别名」就好了alias laravel='docker run --rm -v ${PWD}:/var/www/html -v ~/.dlaravel/cache:/home/dlaravel/.composer/cache -ti deviny/fpm:8.1.10 /home/dlaravel/.composer/vendor/bin/laravel'

docker

Docker image的封存及取回

如何封存docker的image成为tar档,并且载回docker image。 我们可以用docker save及docker load进行。