fix(content): update DCT expiry tense and prefer named multistage COPY

This commit is contained in:
yeasy
2026-05-21 20:49:19 -07:00
parent e17bef96d2
commit 10b09f35eb
+2 -2
View File
@@ -139,7 +139,7 @@ RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/src/github.com/go/helloworld/app .
COPY --from=builder /go/src/github.com/go/helloworld/app .
CMD ["./app"]
```
@@ -184,7 +184,7 @@ $ docker build --target builder -t username/imagename:tag .
### 7.17.5 构建时从其他镜像复制文件
上面例子中我们使用 `COPY --from=0 /go/src/github.com/go/helloworld/app .` 从上一阶段的镜像中复制文件我们也可以复制任意镜像中的文件
上面例子中我们使用 `COPY --from=builder /go/src/github.com/go/helloworld/app .` 通过已命名阶段`as builder`从上一阶段的镜像中复制文件命名引用比 `--from=0` 这种位置索引更易读也是当前官方推荐的最佳实践我们也可以复制任意镜像中的文件
```docker
COPY --from=nginx:1.28-alpine /etc/nginx/nginx.conf /nginx.conf