项目作者: iamvickyav

项目描述 :
SpringBoot Web application + Tomcat running in Docker for deployment
高级语言: Java
项目地址: git://github.com/iamvickyav/spring-boot-docker-tomcat.git
创建时间: 2020-03-03T18:19:07Z
项目社区:https://github.com/iamvickyav/spring-boot-docker-tomcat

开源协议:GNU General Public License v3.0

下载


How to run SpringBoot application in Tomcat with Docker

Note: In order to run your Spring Boot app in standalone tomcat, please do make the code changes mentioned in Deploying SpringBoot application in Standalone Tomcat

Dockerfile explained

  1. FROM tomcat:8.5-jdk11-openjdk-slim
  2. ADD target/sample.war /usr/local/tomcat/webapps/
  3. EXPOSE 8080
  4. CMD ["catalina.sh", "run"]
Keyword Usage
FROM Base image on top of which our custom image is to be build
ADD Copy war file into webapps folder inside Docker
EXPOSE Expose port 8080 outside Docker container
CMD The command to be executed when the Docker image is run

Now run the command

  1. > docker-compose up --build

Note : —build is used to build images before starting the container instead of using the existing image

Above command will start processing docker-compose.yml file. Since we specified build: . in docker-compose.yml file, it will look for Dockerfile in current directory & build a custom image using the same.

Once the docker container is up, try hitting http://localhost:8080/sample/index?name=Vicky