Docker - 复制失败:在构建上下文中找不到文件或被 .dockerignore 排除:stat test.com:文件不存在
Docker - COPY failed: file not found in build context or excluded by .dockerignore: stat test.com: file does not exist
我有以下 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文件,但是为什么会出现错误?
从主机COPY副本。
此处您要从容器内部进行复制。你用 RUN cp
代替。将您的声明更改为
RUN cp ./test.com /usr/share/nginx/html
我有以下 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文件,但是为什么会出现错误?
从主机COPY副本。
此处您要从容器内部进行复制。你用 RUN cp
代替。将您的声明更改为
RUN cp ./test.com /usr/share/nginx/html