Fix heading hierarchy

This commit is contained in:
baohua
2026-03-05 19:24:01 -08:00
parent f5cfa4140a
commit 70ef2cba58
14 changed files with 231 additions and 61 deletions

View File

@@ -118,7 +118,7 @@ go/helloworld 2 f7cf3465432c 22 seconds ago 6.47MB
go/helloworld 1 f55d3e16affc 2 minutes ago 295MB
```
## 7.17 使用多阶段构建
### 7.17.3 使用多阶段构建
为解决以上问题Docker v17.05 开始支持多阶段构建 (`multistage builds`)使用多阶段构建我们就可以很容易解决前面提到的问题并且只需要编写一个 `Dockerfile`
@@ -167,7 +167,7 @@ go/helloworld 1 f55d3e16affc 2 minutes ago 295MB
很明显使用多阶段构建的镜像体积小同时也完美解决了上边提到的问题
### 7.17.1 只构建某一阶段的镜像
### 7.17.4 只构建某一阶段的镜像
我们可以使用 `as` 来为某一阶段命名例如
@@ -181,7 +181,7 @@ FROM golang:alpine as builder
$ docker build --target builder -t username/imagename:tag .
```
### 7.17.2 构建时从其他镜像复制文件
### 7.17.5 构建时从其他镜像复制文件
上面例子中我们使用 `COPY --from=0 /go/src/github.com/go/helloworld/app .` 从上一阶段的镜像中复制文件我们也可以复制任意镜像中的文件