Dockerfile ADD failed : No Source files were specified

user2301 picture user2301 · Nov 14, 2017 · Viewed 30.8k times · Source

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

Answer

samprog picture samprog · Nov 14, 2017

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