0

I have built a simple hello world rest service using spring boot. On my local machine (Ubuntu 14.04) when I run mvn package command, a runnable jar is getting created under target folder: equation-1.0-SNAPSHOT.jar. When I run this jar using java -jar equation-1.0-SNAPSHOT.jar I can see the hello world message via browser.

Then I build a docker image using docker build -t hello:0.1 .. My Dockerfile looks like below.

FROM java:8

COPY ./target/equation-1.0-SNAPSHOT.jar ./app.jar

EXPOSE 8080

CMD java -jar app.jar

Image gets built successfully and when I run this image using docker run -it -p 5000:8080 hello:0.1 I can see hello world message on http://localhost:5000/hello.

So far so good....

Code exists on github and I linked this github repo to Docker Hub. When I trigger an automated build on Docker Hub it is failing with a target/equation-1.0-SNAPSHOT.jar: no such file or directory message. Below is all Logs I see.

Starting to clone
Cloning into '.'... 
Cloning done 
Starting Build 
KernelVersion: 3.13.0-40-generic 
Os: linux 
BuildTime: 2016-02-22T21:37:01.910365059+00:00 
ApiVersion: 1.22 
Version: 1.10.2 
GitCommit: c3959b1 
Arch: amd64 
GoVersion: go1.5.3 
Starting build of index.docker.io/mehmetatas/equation-solver:latest... 
Step 1 : FROM java:8
 ---> 80a9d37df88e 
Step 2 : COPY ./target/equation-1.0-SNAPSHOT.jar ./app.jar 
lstat target/equation-1.0-SNAPSHOT.jar: no such file or directory
Mehmet Ataş
  • 11,081
  • 6
  • 51
  • 78
  • 1
    I'm not an expert here, but I assume that DockerHub doesn't have access to your packaged *.jar file. Is DockerHub able to build Maven artifacts and include them into docker build? I assume no. It's mainl purpose is to build docker images from Dockerfiles. So you should rather provide a Dockerfile which downloads the *.jar from external server, maybe from maven repo? – gmaslowski Apr 20 '16 at 20:29
  • Yes, it turns out Docker Hub does not build Java (or any other) code. It only builds Docker images from Dockerfile. So, I need to use one of the solutions discussed [here](http://stackoverflow.com/questions/31696439/how-to-build-a-docker-container-for-a-java-app?rq=1) – Mehmet Ataş Apr 21 '16 at 07:15

0 Answers0