复制未指定源文件

复制未指定源文件

我正在尝试将 Docker 容器部署到 AWS CodeBuild,但它在以下步骤上不断失败:

COPY dist/* /var/www/html/

我确信该目录中有某些内容,为了确保万无一失,我运行了以下命令ls dist

Step 4 : RUN ls dist
---> Running in cc6a985f54dd
1.1.329fd43c10e3d0fc91b9.js
3.3.d0a0148e036318c95bfe.js
4.4.d85fbfa6409009fb6e4c.js
app.a6626f87bbfc6e67618d.js
app.cd527cf8dea96798229c62fb7d983606.css
favicon.ico
humans.txt
index.html
robots.txt
vendor.d81f28030613dd8760c0.js

我的docker文件:

FROM jaronoff/listmkr-prod
# Remove the default nginx index.html
RUN rm -rf /var/www/html/index.nginx-debian.html

RUN npm run deploy:prod
# Copy the contents of the dist directory over to the nginx web root

RUN ls dist

COPY dist/* /var/www/html/
# Expose the public http port
EXPOSE 80
# Start server
CMD ["nginx", "-g", "daemon off;"]

答案1

DockerfileCOPY命令会将文件从构建“上下文”复制到您的镜像中。构建上下文是您在构建命令末尾传递的文件夹。例如,在docker build -t myimage:latest .命令中,.是您的上下文。要使用该COPY命令,“dist/*”必须存在于其中。

您的RUN ls dist命令将列出您正在构建的镜像内的目录。如果您想将文件从镜像中的一个位置复制到另一个位置,您可以执行以下操作:

RUN cp -a dist/* /var/www/html/

相关内容