1

The following is my root-directory:

andrej:
  - docker/CodeExperiments.jar
  - docker2/Dockerfile

Here are the contents of my Dockerfile:

FROM java:8
ADD docker/CodeExperiments.jar docker/
RUN javac BirthDayTask.java

And this is the command I am running:

docker build -t newfile docker2

Which results in the following error message:

ADD failed: stat /var/lib/docker/tmp/docker-builder946291442/docker/CodeExperiments.jar: no such file or directory

What am I doing wrong?

oxr463
  • 1,573
  • 3
  • 14
  • 34
Jelly
  • 972
  • 1
  • 17
  • 40

2 Answers2

2

CodeExperiments is located in docker folder while Dockerfile is located in docker2.

Place them both in the same folder or at least place CodeExperiments in a child folder of the Dockerfile and reference from there.

Jesus Galvan
  • 572
  • 3
  • 9
1

When you

ADD docker/CodeExperiments.jar docker/

it is relative to the context directory, which is the directory named in the docker build command. That means you need to pass the current directory as the directory argument to docker build. By default it's looking for Dockerfile in that directory, so you also need a -f option to point at an alternate file.

Together this looks like:

docker build -t newfile -f docker2/Dockerfile .
David Maze
  • 130,717
  • 29
  • 175
  • 215