mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-28 12:45:23 +00:00
Add blank lines before headers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user