Skip to content

Docker with Maven

Somkiat Puisungnoen edited this page Nov 2, 2017 · 1 revision

Step 1 : Clone code example form github

git clone https://github.com/up1/maven_java_web_example
cd maven_java_web_example

Step 2 : Build and create WAR file with Apache Maven

Using the Apache Maven Image

docker container run --rm -v $(pwd):/src \
 -w /src \
 maven:3.5.2-jdk-8-alpine \
 mvn clean package

Step 3 : Deploy WAR file into Apache Tomcat

Using the Apache Tomcat Image

docker container run -d -v $(pwd)/target/api.war:/usr/local/tomcat/webapps/api.war \
  -p 8080:8080 \
  tomcat:9.0.1-jre8-alpine

and open with URL http://localhost:8080/api/hello

Clone this wiki locally