gpt4 book ai didi

docker - 使用 docker 时如何执行 ../COPY

转载 作者:行者123 更新时间:2023-12-02 18:48:33 25 4
gpt4 key购买 nike

我正在尝试使用 COPY 将 package.json 文件复制到我的容器中,所以我做了

COPY package*.json .

这是有效的,但现在我正在尝试复制这个 package.json ,它与 Dockerfile 不在同一文件夹中。所以我尝试了:

COPY ../../package*.json .

COPY ./../../package*.json .

没有成功。

当我尝试复制 Dockerfile 中的文件时,如何返回文件夹?没有关于 COPY 命令文档执行某些操作的信息。

最佳答案

不可能 COPY来自构建上下文外部的文件:

The <src> path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.
source: https://docs.docker.com/engine/reference/builder/#copy

关于docker - 使用 docker 时如何执行 ../COPY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51424055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com