Add blank lines around headers

This commit is contained in:
yeasy
2026-03-24 09:27:04 -07:00
parent 857e3b73f6
commit ae8636e96f
112 changed files with 468 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ $ docker exec -it 容器名 /bin/bash
$ docker exec -it 容器名 /bin/sh
```
#### 参数说明
| 参数 | 作用 |
@@ -67,6 +68,7 @@ $ docker ps
CONTAINER ID IMAGE STATUS NAMES
69d137adef7a ubuntu Up 2 minutes myubuntu
```
#### 执行单条命令
不进入交互模式直接执行命令
@@ -84,6 +86,7 @@ $ docker exec myubuntu cat /etc/nginx/nginx.conf
$ docker exec -u root myubuntu apt update
```
#### 只用 -i 不用 -t 的区别
```bash
@@ -112,6 +115,7 @@ root@69d137adef7a:/# # 有提示符
```bash
$ docker attach 容器名
```
#### 工作原理
`attach` 会附加到容器的 **主进程** (PID 1) 的标准输入输出
@@ -126,6 +130,7 @@ flowchart LR
end
Attach["docker attach"] -->|"附加到这里"| P1
```
#### docker attach 示例
```bash
@@ -139,6 +144,7 @@ $ docker run -dit --name myubuntu ubuntu
$ docker attach myubuntu
root@243c32535da7:/#
```
#### 重要警告
** attach 会话中输入 `exit` 或按 `Ctrl+D` 会导致容器停止**
@@ -224,6 +230,7 @@ $ docker exec myapp tail -f /var/log/app.log
$ docker exec myapp python manage.py migrate
```
#### 2. 生产环境避免进入容器
笔者建议生产环境应尽量避免进入容器直接操作而是通过
@@ -261,6 +268,7 @@ $ docker debug myapp
```bash
$ docker exec -it myapp /bin/sh
```
#### Q需要 root 权限
```bash