【问题标题】:Docker - COPY failed: file not found in build context or excluded by .dockerignore: stat test.com: file does not exist [duplicate]Docker-复制失败:在构建上下文中找不到文件或被.dockerignore排除:stat test.com:文件不存在[重复]
【发布时间】:2022-01-12 13:32:47
【问题描述】:

我有以下 dockerfile:

FROM nginx:1.21.3-alpine

COPY ./conf.d /etc/nginx/conf.d

RUN apk update && apk add git
RUN git clone https://username:token@github.com/username/test.com.git

RUN echo $(ls -l)

COPY ./test.com /usr/share/nginx/html

我正在下载测试存储库的内容。它包含 index.html 文件。接下来,我尝试将存储库文件夹的内容复制到 /usr/share/nginx/html 文件夹,但出现错误:

COPY failed: file not found in build context or excluded by .dockerignore: stat test.com: file does not exist

我添加了命令 ls -l 的执行,列表中包含一个 test.com 文件夹和 index.html 文件,但是为什么会出现错误呢?

【问题讨论】:

    标签: docker dockerfile


    【解决方案1】:

    从主机复制副本。

    在这里您要从容器内部复制。你可以用RUN cp 来代替。将您的声明更改为

    RUN cp ./test.com /usr/share/nginx/html
    

    【讨论】:

      猜你喜欢
      • 2022-06-30
      • 2021-12-19
      • 1970-01-01
      • 2020-05-15
      • 2022-01-11
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 2022-10-15
      相关资源
      最近更新 更多