I am pretty new to Tomcat and Docker - so I am probably missing a Tomcat fundamental somewhere in this question.
What I am trying to do is build a Docker container that runs a SpringBoot Restful web service that just returns some static data. This is all running on OSX so I am using Boot2Docker as well.
I've written my own Dockerfile to build the container that my app runs in:
FROM tomcat:8.0.20-jre8 RUN mkdir /usr/local/tomcat/webapps/myapp COPY /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/myapp/
This Dockerfile works fine and I am able to start the container from the created image.
docker build -t myapp . docker run -it --rm -p 8888:8080 myapp
This container starts correctly and outputs no errors and displays the message saying my app was deployed.
22-Mar-2015 23:07:21.217 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/myapp
The container also correctly has the myapp.war copied to the path described in the Dockerfile. Moreover I am able to navigate to Tomcat default page to confirm that Tomcat is running, I can also hit all the examples, etc.
To the problem, when I navigate to http://192.168.59.103:8888/myapp/getData I get a 404. I can't quite figure out why. Am I missing something regarding a .war deploy to Tomcat?
Step 1: Install Tomcat on OpenShift. Step 2: Create a new project. Step 3: Create the Java web application. Step 4: Access the Tomcat Manager on OpenShift.
Docker Hub is like the GitHub of Docker Containers. There are thousands of apps and examples you can use. To set up your own public or private repository to start deploying your apps, just go to the Docker Hub website. You can use the Docker hub to push and pull changes in your app to different machines.
You are trying to copy the war
file to a directory below webapps
. The war file should be copied into the webapps
directory.
Remove the mkdir command, and copy the war
file like this:
COPY /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/myapp.war
Tomcat will extract the war if autodeploy
is turned on.
There's a oneliner for this one.
You can simply run,
docker run -v /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war:/usr/local/tomcat/webapps/myapp.war -it -p 8080:8080 tomcat
This will copy the war file to webapps directory and get your app running in no time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With