Fix and improve

This commit is contained in:
Baohua Yang
2026-02-12 16:51:50 -08:00
parent bae82e993a
commit 0835f8467a
100 changed files with 280 additions and 622 deletions

View File

@@ -2,8 +2,6 @@
### 基本语法
具体内容如下
```docker
RUN <command>
RUN ["executable", "param1", "param2"]
@@ -17,8 +15,6 @@ RUN ["executable", "param1", "param2"]
#### 1. Shell 格式
具体内容如下
```docker
RUN apt-get update
```
@@ -32,8 +28,6 @@ RUN apt-get update
#### 2. Exec 格式
具体内容如下
```docker
RUN ["apt-get", "update"]
```
@@ -105,8 +99,6 @@ RUN wget http://url | gzip -d > file
#### Q: 为什么 `RUN cd /app` 不生效
具体内容如下
```docker
RUN cd /app
RUN touch hello.txt
@@ -125,8 +117,6 @@ RUN touch hello.txt
#### Q: 环境变量不生效
具体内容如下
```docker
RUN export MY_VAR=hello
RUN echo $MY_VAR
@@ -189,6 +179,6 @@ RUN --mount=type=secret,id=mysecret \
### 延伸阅读
- [CMD 容器启动命令](cmd.md)容器启动时的命令
- [WORKDIR 指定工作目录](workdir.md)改变目录
- [Dockerfile 最佳实践](../../16_appendix/16.1_best_practices.md)
- [CMD 容器启动命令](7.4_cmd.md)容器启动时的命令
- [WORKDIR 指定工作目录](7.10_workdir.md)改变目录
- [Dockerfile 最佳实践](../16_appendix/16.1_best_practices.md)