Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerfile ADD failed : No Source files were specified

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
like image 867
user2301 Avatar asked Nov 14 '17 09:11

user2301


People also ask

What is Workdir in Dockerfile?

WORKDIR instruction is used to set the working directory for all the subsequent Dockerfile instructions. Some frequently used instructions in a Dockerfile are RUN, ADD, CMD, ENTRYPOINT, and COPY. If the WORKDIR is not manually created, it gets created automatically during the processing of the instructions.

Where is the Dockerignore file?

dockerignore file is on the root directory of your context, it will ignore it if it is somewhere in the subfolder.

What is difference between ADD and copy in Dockerfile?

COPY is a docker file command that copies files from a local source location to a destination in the Docker container. ADD command is used to copy files/directories into a Docker image. It only has only one assigned function. It can also copy files from a URL.


2 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

like image 200
samprog Avatar answered Oct 16 '22 21:10

samprog


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.

like image 36
S.Dayneko Avatar answered Oct 16 '22 22:10

S.Dayneko