Dockerfile ADD failed : No Source files were specified

Viewed 43256

I have a python project created in eclipse. I am creating for first time a Dockerfile.The Docker build always fails showing this

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?

-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
4 Answers

It generally is recommended to use COPY before ADD, because it serves a lesser purpose and is somewhat more lightweight.

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:

Reference

Best Practices

Postgresql example

In a Java project, the problem was the lack of a JAR file in the target folder. It was necessary to make (in the case of maven) the mvn clean package, and then make the docker run command.

I had the same error message. It was a .dockerignore next to my Dockerfile wich was ignoring my file.

I got the same error for my spring boot microservice. I have rebuild my microservice using

mvn clean install

And run the docker build command again, this worked for me.

Related