Add blank lines before headers

This commit is contained in:
yeasy
2026-03-21 12:57:51 -07:00
parent 0648f63979
commit 312f8fea42
76 changed files with 411 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ Registry地址 用户名 仓库名 标签
#### 示例
```bash
## 完整格式
$ docker pull docker.io/library/ubuntu:24.04
@@ -127,6 +128,7 @@ $ docker pull --platform linux/amd64 nginx
拉取镜像后可以基于它启动容器
```bash
## 拉取镜像
$ docker pull ubuntu:24.04
@@ -170,6 +172,7 @@ root@e7009c6ce357:/# exit
```bash
$ sudo systemctl restart docker # Linux
## 或在 Docker Desktop 中重启
```
@@ -226,6 +229,7 @@ Error: pull access denied, repository does not exist
#### Q磁盘空间不足
```bash
## 清理未使用的镜像
$ docker image prune

View File

@@ -82,6 +82,7 @@ Build Cache 0 0 0B 0B
#### 按仓库名过滤
```bash
## 列出所有 ubuntu 镜像
$ docker images ubuntu
@@ -110,6 +111,7 @@ ubuntu 24.04 329ed837d508 78MB
| `reference=pattern` | 按名称模式 | `-f reference='*:latest'` |
```bash
## 列出 nginx 之后创建的镜像
$ docker images -f since=nginx:latest
@@ -147,6 +149,7 @@ REPOSITORY TAG IMAGE ID SIZE
#### 处理虚悬镜像
```bash
## 列出虚悬镜像
$ docker images -f dangling=true
@@ -190,6 +193,7 @@ $ docker images -q
常用于配合其他命令
```bash
## 删除所有镜像
$ docker rmi $(docker images -q)
@@ -218,6 +222,7 @@ nginx latest sha256:b4f0e0bdeb5... e43d811ce2f4
使用 Go 模板语法自定义输出
```bash
## 只显示 ID 和仓库名
$ docker images --format "{{.ID}}: {{.Repository}}"
@@ -251,6 +256,7 @@ ubuntu 24.04 78MB
### 4.2.8 常用命令组合
```bash
## 列出所有镜像及其大小,按大小排序(需要系统 sort 命令)
$ docker images --format "{{.Size}}\t{{.Repository}}:{{.Tag}}" | sort -h

View File

@@ -53,6 +53,7 @@ Deleted: sha256:501ad78535f0...
摘要删除最精确适用于 CI/CD 场景
```bash
## 查看镜像摘要
$ docker images --digests
@@ -125,6 +126,7 @@ flowchart TD
虚悬镜像 (dangling)没有标签的镜像通常是旧版本被新版本覆盖后产生的
```bash
## 查看虚悬镜像
$ docker images -f dangling=true
@@ -141,6 +143,7 @@ $ docker image prune -f
#### 删除所有未使用的镜像
```bash
## 删除所有没有被容器使用的镜像
$ docker image prune -a
@@ -153,6 +156,7 @@ $ docker image prune -a --filter "until=24h"
#### 按条件删除
```bash
## 删除所有 redis 镜像
$ docker rmi $(docker images -q redis)
@@ -183,6 +187,7 @@ Error: conflict: unable to remove repository reference "nginx"
**解决方案**
```bash
## 方案1先删除依赖的容器
$ docker rm abc123
@@ -203,6 +208,7 @@ ubuntu latest ca2b0f26964c # 同一个镜像
$ docker rmi ubuntu:24.04
Untagged: ubuntu:24.04
## 只是移除标签,镜像仍存在(因为还有 ubuntu:latest 指向它)
```
@@ -238,6 +244,7 @@ Error: image has dependent child images
#### 开发环境
```bash
## 定期清理虚悬镜像
$ docker image prune -f
@@ -250,6 +257,7 @@ $ docker system prune -a
#### CI/CD 环境
```bash
## 只保留最近使用的镜像
$ docker image prune -a --filter "until=72h" -f

View File

@@ -151,6 +151,7 @@ Sending build context to Docker daemon 2.048 kB
或许你已经注意到了`docker build` 还支持从 URL 构建比如可以直接从 Git repo 中构建
```bash
## $env:DOCKER_BUILDKIT=0
## export DOCKER_BUILDKIT=0