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?

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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 . 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.