I am trying to learn my way around Docker. I want to build a container/image for my java application. The Docker file looks like this:
FROM openjdk:7
COPY . C:/Users/name/Documents/NetBeansProjects/project1/src/mainpckg
WORKDIR C:/Users/name/Documents/NetBeansProjects/project1/src/mainpckg
RUN javac Main.java
CMD java Main
And i am calling it like this:
docker build -t my-java-app .
But it gives the following error:
$ docker build -t my-java-app .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM openjdk:7
---> 4a42f05dc422
Step 2 : COPY . C:/Users/name/Documents/NetBeansProjects/project1
/src/mainpckg
---> Using cache
---> 301de702fad9
Step 3 : WORKDIR C:/Users/name/Documents/NetBeansProjects/project1
s/src/mainpckg
---> Using cache
---> 1868e40b329e
Step 4 : RUN javac Main.java
---> Running in 66d7d769f425
javac: file not found: Main.java
Usage: javac <options> <source files>
use -help for a list of possible options
The command '/bin/sh -c javac Main.java' returned a non-zero code:
2
I also tried the solution given here:
docker run --rm -v /mypathhere/mycode java:7 sh -c "cd mycode; javac mycode.java"
but without any results, i still got this error:
javac: file not found: Main.java
Usage: javac <options> <source files>
use -help for a list of possible options
C:/...is a valid path. Do you want to try it with something like/appand see if that works better?