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 @@ mycontainer
#### 强制删除运行中的容器
```bash
## 不加 -f 会报错
$ docker rm running_container
@@ -48,6 +49,7 @@ running_container
#### 删除容器及其数据卷
```bash
## 删除容器时同时删除其匿名卷
$ docker rm -v mycontainer
@@ -62,6 +64,7 @@ $ docker rm -v mycontainer
#### 删除所有已停止的容器
```bash
## 方式一:使用 prune 命令(推荐)
$ docker container prune
@@ -81,6 +84,7 @@ $ docker container prune -f
#### 删除所有容器包括运行中的
```bash
## 先停止所有容器,再删除
$ docker stop $(docker ps -q)
@@ -94,6 +98,7 @@ $ docker rm -f $(docker ps -aq)
#### 按条件删除
```bash
## 删除所有已退出的容器
$ docker rm $(docker ps -aq -f status=exited)
@@ -125,6 +130,7 @@ $ docker container prune --filter "until=24h"
#### 示例
```bash
## 删除所有基于 nginx 镜像的容器
$ docker rm $(docker ps -aq -f ancestor=nginx)
@@ -141,6 +147,7 @@ $ docker rm $(docker ps -aq -f status=created)
> 有容器依赖的镜像无法删除
```bash
## 尝试删除有容器依赖的镜像
$ docker image rm nginx
@@ -159,6 +166,7 @@ $ docker image rm nginx
#### 开发环境
```bash
## 定期清理已停止的容器
$ docker container prune -f
@@ -171,9 +179,11 @@ $ docker system prune -f
#### 生产环境
```bash
## 使用 --rm 参数运行临时容器
$ docker run --rm ubuntu echo "Hello"
## 容器退出后自动删除
## 定期清理(设置保留时间)
@@ -185,6 +195,7 @@ $ docker container prune --filter "until=168h" # 保留 7 天内的
```bash
#!/bin/bash
## cleanup.sh - Docker 资源清理脚本
echo "清理已停止的容器..."
@@ -218,6 +229,7 @@ Error: container is running
```bash
$ docker stop mycontainer
$ docker rm mycontainer
## 或
$ docker rm -f mycontainer
@@ -234,6 +246,7 @@ $ docker rm -f mycontainer
解决
```bash
## 查看空间占用
$ docker system df