FROM tomcat:8.0-alpine
RUN rm -rf /Users/firstname.lastname/Desktop/Backup/apache-tomcat-9.0.30/webapps/*
ADD./target/restfullapi-0.0.1-SNAPSHOT.war /Users/firstname.lastname/Desktop/Backup/apache-tomcat-9.0.30/webapps/restfullapi.war
EXPOSE 8089
CMD ["catalina.sh", "run"]
Once I build the.war file I do the following steps:
docker build -t restfullapi.war. docker run -d -p 8085:8089 restfullapi.war Now when I open localhost:8085 I am able to see only tomcat home page which is correct, but the problem is If I try to access -->> localhost:8085/restfullapi/movies I get 404 error.
and here is my pom.xml
http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.dev.movies restfullapi war 0.0.1-SNAPSHOT RestFulAPI Maven Webapp http://maven.apache.org junit junit 3.8.1 test
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.3.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
</dependencies>
<build>
<finalName>restfullapi</finalName>
</build>
You can run a SpringBoot application in Docker using the default embedded Tomcat. This avoids the need to create a WAR file and provide Tomcat yourself.
FROM adoptopenjdk/openjdk11:latest
RUN mkdir -p /software/app
ADD target/restfullapi.jar /software/app/restfullapi.jar
ENV port=8888
CMD java -jar /software/app/restfullapi.jar -Dspring.profiles.active=${SPRING_ACTIVE_PROFILE}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.