Docker's container operation is no problem, and the next step is to integrate with our Tomcat app to deliver the actual service.
According to the official web, two ways of packaging and publishing .
One is to build maven Dockerdirectly and then package it directly by placing the war package under the corresponding build file.
The other is to manually add the war package , pack it into the container, and then start the container and load the war.
The first to build Maven Docker after the operation of the time to toss, first the following the second kind of direct import, binding war to do a real exercise.
So the first is to build Dockerfile.
Next, write the code in Dockerfile that corresponds to the location of the war package resource.
From Lekko/tomcat8
ADD ./hpapppay.war usr/local/tomcat/webapps/
CMD ["catalina.sh", "Run"]
The third is to execute, the dockerfile, to let this resource load into this docker.
[Root@master tomcat4docker]# Docker build-t lekko/tomcat8/usr/local/tomcat4docker/
Sending build context to Docker Daemon 17.59 MB
step 1:from lekko/tomcat8
---> 30d95ba23356
step 2:add/hpapppay.war usr/local/tomcat/ webapps/
---> 09C0C62ADABF
removing Intermediate container e1406510edfa
Step 3:cmd catalina.sh Run
---> Running in 3f1b4b34ff9e
---> 0246df675802
removing Intermediate container 3f1b4b34ff9e
Successfully built 0246df675802
At this point, we run the image again to see the correct result.
If the result does not appear as expected, use the
Docker exec-it Containerid/bin/bash
For viewing and configuration.