mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 08:27:25 +00:00
fix(content): update DCT expiry tense and prefer named multistage COPY
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user