mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-11 04:14:38 +00:00
Simplify words and fix format issues
This commit is contained in:
@@ -27,8 +27,6 @@ $ docker image rm [选项] <镜像1> [<镜像2> ...]
|
||||
|
||||
#### 使用短 ID 删除
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker image ls
|
||||
REPOSITORY TAG IMAGE ID SIZE
|
||||
@@ -44,8 +42,6 @@ Deleted: sha256:501ad78535f0...
|
||||
|
||||
#### 使用镜像名删除
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker rmi redis:alpine
|
||||
Untagged: redis:alpine
|
||||
@@ -87,8 +83,6 @@ Deleted: sha256:32770d1dcf835f192cafd6b9263b7b597a1778a403a109e2cc2ee866f74adf23
|
||||
|
||||
#### Untagged vs Deleted
|
||||
|
||||
相关信息如下表:
|
||||
|
||||
| 操作 | 含义 |
|
||||
|------|------|
|
||||
| **Untagged** | 移除镜像的标签 |
|
||||
@@ -146,8 +140,6 @@ $ docker image prune -f
|
||||
|
||||
#### 删除所有未使用的镜像
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
## 删除所有没有被容器使用的镜像
|
||||
|
||||
@@ -160,8 +152,6 @@ $ docker image prune -a --filter "until=24h"
|
||||
|
||||
#### 按条件删除
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
## 删除所有 redis 镜像
|
||||
|
||||
@@ -184,8 +174,6 @@ $ docker image prune -a --filter "until=168h" # 7天前
|
||||
|
||||
#### 原因一:有容器依赖
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker rmi nginx
|
||||
Error: conflict: unable to remove repository reference "nginx"
|
||||
@@ -207,8 +195,6 @@ $ docker rmi -f nginx
|
||||
|
||||
#### 原因二:多个标签指向同一镜像
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID
|
||||
@@ -225,8 +211,6 @@ Untagged: ubuntu:24.04
|
||||
|
||||
#### 原因三:被其他镜像依赖 (中间层)
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker rmi some_base_image
|
||||
Error: image has dependent child images
|
||||
@@ -238,8 +222,6 @@ Error: image has dependent child images
|
||||
|
||||
### 4.3.6 常用过滤条件
|
||||
|
||||
相关信息如下表:
|
||||
|
||||
| 过滤条件 | 说明 | 示例 |
|
||||
|---------|------|------|
|
||||
| `dangling=true` | 虚悬镜像 | `-f dangling=true` |
|
||||
@@ -256,8 +238,6 @@ Error: image has dependent child images
|
||||
|
||||
#### 开发环境
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
## 定期清理虚悬镜像
|
||||
|
||||
@@ -270,8 +250,6 @@ $ docker system prune -a
|
||||
|
||||
#### CI/CD 环境
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
## 只保留最近使用的镜像
|
||||
|
||||
@@ -280,8 +258,6 @@ $ docker image prune -a --filter "until=72h" -f
|
||||
|
||||
#### 查看空间占用
|
||||
|
||||
运行以下命令:
|
||||
|
||||
```bash
|
||||
$ docker system df
|
||||
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
|
||||
|
||||
Reference in New Issue
Block a user