From 10b09f35eb16e3d7474a5a97a7f086e476b9cef5 Mon Sep 17 00:00:00 2001 From: yeasy Date: Thu, 21 May 2026 20:49:19 -0700 Subject: [PATCH] fix(content): update DCT expiry tense and prefer named multistage COPY --- 07_dockerfile/7.17_multistage_builds.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/07_dockerfile/7.17_multistage_builds.md b/07_dockerfile/7.17_multistage_builds.md index 80f027b..c0d585c 100644 --- a/07_dockerfile/7.17_multistage_builds.md +++ b/07_dockerfile/7.17_multistage_builds.md @@ -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