add some posts

This commit is contained in:
zibright
2025-07-22 00:44:40 +08:00
parent c40fa690cf
commit 127dc36845
4 changed files with 204 additions and 8 deletions

View File

@@ -0,0 +1,30 @@
# Docker容器和镜像的删除操作
## 容器和镜像的关系
简单来说,镜像是文件,容器是进程。
容器是基于镜像创建的,即容器中的进程依赖于镜像中的文件。
docker利用容器来运行应用docker容器是由docker镜像创建的运行实例。
![容器与镜像](https://i-blog.csdnimg.cn/blog_migrate/1239ccc5a805c44d9ecb6bc844ac9457.jpeg)
### 删除镜像的操作步骤
#### 一、停止正在运行的镜像创建的容器
查看正在运行的容器
```shell
docker ps
```
停止对应容器
```shell
docker stop xxx
```
xxx 是 docker ps 命令出来的容器 CONTAINER ID 的前三位
删除对应的容器
```shell
docker rm xxx
```
查看镜像
```shell
docker images
```
同理yyy 是 docker images 命令出来的镜像 IMAGE ID 的前三位
删除对应的镜像
```shell
docker rmi yyy
```