Remove blank lines after code block markers

This commit is contained in:
yeasy
2026-03-21 22:36:09 -07:00
parent 312f8fea42
commit 9ac19d79ee
132 changed files with 0 additions and 1517 deletions

View File

@@ -14,7 +14,6 @@ nginx latest 05a60462f8ba 5 days ago 181MB
ubuntu 24.04 329ed837d508 3 days ago 78MB
ubuntu noble 329ed837d508 3 days ago 78MB
```
> 💡 `docker images` `docker image ls` 的简写两者等效
---
@@ -59,7 +58,6 @@ ubuntu:24.04 nginx:latest redis:latest
▼ │
共享基础层 ◄───────────────────┘
```
因此`docker image ls` 中各镜像大小之和 > 实际磁盘占用
#### 查看实际空间占用
@@ -72,7 +70,6 @@ Containers 5 2 100MB 80MB (80%)
Local Volumes 8 2 500MB 400MB (80%)
Build Cache 0 0 0B 0B
```
---
### 4.2.4 过滤镜像
@@ -82,7 +79,6 @@ Build Cache 0 0 0B 0B
#### 按仓库名过滤
```bash
## 列出所有 ubuntu 镜像
$ docker images ubuntu
@@ -91,7 +87,6 @@ ubuntu 24.04 329ed837d508 78MB
ubuntu noble 329ed837d508 78MB
ubuntu 22.04 a1b2c3d4e5f6 72MB
```
#### 按仓库名和标签过滤
```bash
@@ -99,7 +94,6 @@ $ docker images ubuntu:24.04
REPOSITORY TAG IMAGE ID SIZE
ubuntu 24.04 329ed837d508 78MB
```
#### 使用过滤器 --filter
| 过滤条件 | 说明 | 示例 |
@@ -111,7 +105,6 @@ ubuntu 24.04 329ed837d508 78MB
| `reference=pattern` | 按名称模式 | `-f reference='*:latest'` |
```bash
## 列出 nginx 之后创建的镜像
$ docker images -f since=nginx:latest
@@ -124,7 +117,6 @@ $ docker images -f reference='*:latest'
$ docker images -f label=maintainer=example@email.com
```
---
### 4.2.5 虚悬镜像
@@ -140,7 +132,6 @@ $ docker images
REPOSITORY TAG IMAGE ID SIZE
<none> <none> 00285df0df87 342MB
```
#### 产生原因
1. **镜像重新构建**新镜像使用了旧镜像的标签旧镜像标签被移除
@@ -149,7 +140,6 @@ REPOSITORY TAG IMAGE ID SIZE
#### 处理虚悬镜像
```bash
## 列出虚悬镜像
$ docker images -f dangling=true
@@ -158,7 +148,6 @@ $ docker images -f dangling=true
$ docker image prune
```
---
### 4.2.6 中间层镜像
@@ -170,7 +159,6 @@ $ docker image prune
```bash
$ docker images -a
```
会显示很多无标签镜像这些是构建过程中产生的中间层被其他镜像依赖
> 不要删除中间层镜像它们是其他镜像的依赖删除会导致上层镜像无法使用删除顶层镜像时会自动清理不再需要的中间层
@@ -189,11 +177,9 @@ $ docker images -q
05a60462f8ba
329ed837d508
```
常用于配合其他命令
```bash
## 删除所有镜像
$ docker rmi $(docker images -q)
@@ -202,13 +188,11 @@ $ docker rmi $(docker images -q)
$ docker rmi $(docker images -q redis)
```
#### 显示完整 ID
```bash
$ docker images --no-trunc
```
#### 显示摘要
```bash
@@ -216,13 +200,11 @@ $ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID
nginx latest sha256:b4f0e0bdeb5... e43d811ce2f4
```
#### 自定义格式
使用 Go 模板语法自定义输出
```bash
## 只显示 ID 和仓库名
$ docker images --format "{{.ID}}: {{.Repository}}"
@@ -238,7 +220,6 @@ redis latest 183MB
nginx latest 181MB
ubuntu 24.04 78MB
```
#### 可用模板字段
| 字段 | 说明 |
@@ -256,7 +237,6 @@ ubuntu 24.04 78MB
### 4.2.8 常用命令组合
```bash
## 列出所有镜像及其大小,按大小排序(需要系统 sort 命令)
$ docker images --format "{{.Size}}\t{{.Repository}}:{{.Tag}}" | sort -h
@@ -269,5 +249,4 @@ $ docker images --format "{{.Size}}\t{{.Repository}}:{{.Tag}}" | grep -E "^[0-9]
$ docker images --format "{{.Repository}}:{{.Tag}}" > images.txt
```
---