gpt4 book ai didi

docker - 将 Docker 中的 * 文件复制到目录会出错

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

我有以下 Dockerfile

FROM openjdk:8-jdk-alpine
RUN mkdir -p /webpieces
COPY * /webpieces
WORKDIR "/webpieces"
ENTRYPOINT ["./bin/webpiecesexample"]

当我这样构建时,我收到以下错误

Deans-MacBook-Pro:webpiecesexample dean$ docker build -t gcr.io/braided-topic/webpieces2 .
Sending build context to Docker daemon 75.56MB
Step 1/5 : FROM openjdk:8-jdk-alpine
---> a3562aa0b991
Step 2/5 : RUN mkdir -p /webpieces
---> Running in bc615c0cd540
Removing intermediate container bc615c0cd540
---> 69a2f4530c44
Step 3/5 : COPY * /webpieces
When using COPY with more than one source file, the destination must be a directory and end with a /

当我修剪 DockerFile 并仅使用前两行进行构建,然后使用基本 shell 运行以查看目录时,我会在那里看到 webpieces 目录

docker run -it --entrypoint sh gcr.io/braided-topic-266113/webpieces2

我可以 cd 到 webpieces 和一切。为什么复制命令在这里不起作用?

这里是docker版本:

Deans-MacBook-Pro:distributions dean$ docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:22:34 2019
OS/Arch: darwin/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:29:19 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683

最佳答案

When using COPY with more than one source file, the destination must be a directory and end with a /.

COPY 行更改为

COPY * /webpieces/

...it seems to copy the contents of each directory instead of the directories themselves. I would prefer not to name each directory I am moving as we prefer auto-add when we make changes.

使用 . 而不是 * 它将保留所有嵌套。

COPY . /webpieces/

关于docker - 将 Docker 中的 * 文件复制到目录会出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59919757/

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