Files
chill_notes/Docker/基础/docker rm & docker rmi & docker prune 的差异.md
2026-04-15 23:34:33 +08:00

65 lines
2.1 KiB
Markdown
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
**docker rm & docker rmi & docker prune** **的差异**
**docker rm** **** ==删除一个或多个== **容器**
**docker rmi** **:**  ==删除一个或多个== **镜像**
**docker prune**==== ==用来删除不再使用的== **docker** **对象** 
**依据镜像名称来** **删除**
docker rm `docker ps -a |grep 10.10.200.175/rancher/* | awk '{print $1}'`
 docker stop `docker ps -a | awk '{print $1}'`
**Docker rm** **命令**
**语法**
docker rm [OPTIONS] CONTAINER [CONTAINER...]
==OPTIONS====说明:==
- **-f** **:** ==通过====SIGKILL====信号====强制删除====一个运行中的容器==
- **-l** **:** ==移除容器间的网络连接,而非容器本身==
- **-v** **:** ==删除与容器关联的卷==
 
**实例**
==强制删除容器====db01====、====db02======
docker rm -f db01 db02
 
==移除容器== ==my-nginx== ==对容器====db01====的连接,连接名====db01======
docker rm -l db01
 
==删除容器== ==my-nginx====,并删除容器挂载的数据卷:==
docker rm -v my-nginx
 
**Docker rmi** **命令**
**语法**
docker rmi [OPTIONS] IMAGE [IMAGE...]
==OPTIONS====说明:==
- **-f** **:** ==强制删除==
- **--no-prune** **:** ==不移除该镜像的过程镜像,默认移除==
 
**实例**
==强制删除本地镜像== ==mongo:3.2==
docker rmi -f mongo:3.2
![rootxuanwo REPOSITORY mongo tomcat python nglnx my...](Exported%20image%2020260407225313-0.png)
 
**Docker prune** **命令**
==删除== ==所有未被== ==tag== ==标记和未被容器使用的镜像======
docker image prune
 
==删除== ==所有未被容器使用的镜像======
docker image prune -a
 
==删除== ==所有停止运行的容器======
docker container prune
 
==删除== ==所有未被挂载的卷======
docker volume prune
 
==删除== ==所有网络======
docker network prune
 
==删除== ==docker== ==所有资源======
docker system prune
\> 来自 \<[https://www.cnblogs.com/miracle-luna/p/11111907.html](https://www.cnblogs.com/miracle-luna/p/11111907.html)\>