2

I am new to the docker technology. I have a spring boot application running on my local machine. I need to move the target jar file to the docker container.

This spring boot application is contains rest services and some controller will display the view (JSP) with the help of dispatcher servlet.

While creating the container, I am getting 404 Error for the views returned from the dispatcher servlet. What is the command I need to place in my dockerfile to move my static web app folder to the container ?.

Thanks in advance.

Container is working fine for the rest services. Rest services to perform CRUD with mysql server.

My Dockerfile :

FROM openjdk:8

EXPOSE 7070

ADD target/docker_app.jar docker_app.jar

ENTRYPOINT ["java","-jar","docker_app.jar"]
Corey
  • 1,217
  • 3
  • 22
  • 39
  • How do you start the container? Do you map container's exposed port to host?Also I would reccomend using `COPY` instruction instead of `ADD`. – leopal Jan 31 '19 at 14:23
  • @leopal . Thanks for your response. I am exposing 7070 port and mapped the same to container port. Command : sudo docker run -p 7070:7070 --name docker_app --link mysql-docker-container:mysql -d docker_app – ARUNKUMAR SANTHANAM Jan 31 '19 at 14:24
  • @leopal. I have tried with COPY command, Still i am getting same error . Error : There was an unexpected error (type=Not Found, status=404). /WEB-INF/view/login.jsp – ARUNKUMAR SANTHANAM Jan 31 '19 at 14:29

1 Answers1

1

You should not wrap the the web application as jar.

add the following tag in your pom xml

<packaging>war</packaging>

change the Dockerfile command to deploy war file instead of jar.

Dockerfile :

FROM openjdk:8
EXPOSE 7070
ADD target/docker_app.war docker_app.war
ENTRYPOINT ["java","-jar","docker_app.war"]
Naresh
  • 105
  • 1
  • 14