Reputation: 887
I have installed docker in my windows machine and run an image for java installation following instructions from "https://registry.hub.docker.com/u/dockerfile/java/" it allows me to run java commands as expected. But lets say I have a Java application which needs to be run on Jboss or tomcat. How do I create an image for this and how to add my application war file to deploy in server. As I have not much knowledge about creating docker file. It will be really very helful if you can tell how this can be done , so that I can run my application anywhere with Jboss/tomcat server using docker.
Upvotes: 7
Views: 7122
Reputation: 634
Create a Dockerfile like this:
FROM dockerfile/java
# Install Tomcat
RUN sudo apt-get update && sudo apt-get install tomcat7
# Add your webapp file into your docker image into Tomcat's webapps directory
# Your webapp file must be at the same location as your Dockerfile
ADD mywebapp.war /var/lib/tomcat7/webapps/
# Expose TCP port 8080
EXPOSE 8080
# Start Tomcat server
# The last line (the CMD command) is used to make a fake always-running
# command (the tail command); thus, the Docker container will keep running.
CMD sudo service tomcat7 start && tail -f /var/log/tomcat7/catalina.out
Build the image:
$ docker build -t tomcat7-test <Dockerfile's path>
And then, run it:
$ docker run -d -p 8080:8080 tomcat7-test
Upvotes: 9
Reputation: 11
Run this:
sudo apt-get -y install tomcat7
Make sure to add the -y
before install
.
Upvotes: 1