running java applications in docker with jboss or tomcat server running java applications in docker with jboss or tomcat server docker docker

running java applications in docker with jboss or tomcat server


Create a Dockerfile like this:

FROM dockerfile/java# Install TomcatRUN 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 DockerfileADD mywebapp.war /var/lib/tomcat7/webapps/# Expose TCP port 8080EXPOSE 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


Run this:

sudo apt-get -y install tomcat7

Make sure to add the -y before install.