Python Dockerfile 添加失败:未指定源文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47281687/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dockerfile ADD failed : No Source files were specified
提问by user2301
I have a python project created in eclipse. I am creating for first time a Dockerfile.The Docker build always fails showing this
我有一个在 eclipse 中创建的 python 项目。我第一次创建一个 Dockerfile。Docker 构建总是失败显示这个
ADD failed: no source files were specified
添加失败:未指定源文件
I am copying the project directory and adding pydev packages with python modules using ADD command.Below is the python project structure. How to ADD all modules in Dockerfile?
我正在复制项目目录并使用 ADD 命令添加带有 python 模块的 pydev 包。下面是 python 项目结构。如何在 Dockerfile 中添加所有模块?
-Myproject_rootdirectory
-- Client
- __init__.py
- Main.py
--Subscriber1
- domain1
- __init__.py
- d2.py
- domain2
- __init__.py
- d2.py
- __init__.py
--Subscriber2
- domain3
- __init__.py
- d3.py
- domain4
- __init__.py
- d4.py
- __init__.py
采纳答案by samprog
It generally is recommended to use COPY
before ADD
, because it serves a lesser purpose and is somewhat more lightweight.
通常建议使用COPY
before ADD
,因为它的用途较小,并且更轻巧。
To copy your whole directory into the image, just add the following line after editing:
要将整个目录复制到图像中,只需在编辑后添加以下行:
COPY . /path/to/dir/in/image
Some helpful links to start writing dockerfiles:
开始编写 dockerfiles 的一些有用链接:
回答by S.Dayneko
In a Java project, the problem was the lack of a JAR file in the targetfolder. It was necessary to make (in the case of maven) the mvn clean package, and then make the docker runcommand.
在 Java 项目中,问题是目标文件夹中缺少 JAR 文件。有必要制作(在 maven 的情况下)mvn clean package,然后制作docker run命令。
回答by Integrator_7
I got the same error for my spring boot microservice. I have rebuild my microservice using
我的 Spring Boot 微服务遇到了同样的错误。我已经使用重建我的微服务
mvn clean install
And run the docker build command again, this worked for me.
并再次运行 docker build 命令,这对我有用。