Create a docker image and initialize the jdk8 and tomcat environments.
1. Create a Dockerfile:
Create a Dockerfile and download jdk and tomcat in the same directory as Dockerfile.
Dockerfile content:
1 FROM Ubuntu: 14.10 2 MAINTAINER linx 3 4 # ADD java and tomcat to the container 5 ADD jdk-8u31-linux-x64.tar.gz/usr/local/6 ADD apache-tomcat-8.0.20.tar.gz/usr/local/7 8 # configure java and tomcat Environment Variables 9 ENV JAVA_HOME/usr/local/jdk1.8.0 _ 3110 env classpath $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar11 ENV CATALINA_HOME/usr/local/apache-tomcat-8.0.2012 ENV CATALINA_BASE/usr/local/apache-tomcat-8.0.2013 env path $ PATH: $ JAVA_HOME/bin: $ CATALINA_HOME/lib: $ CATALINA_HOME/bin14 15 # port 16 EXPOSE 8080 monitored during container Runtime
Ii. Create an image
1. Run the docker build-t linx/tomcat. Command
3. Enter the container:
1. run docker run-I-t-p 18080: 8080 linx/tomcat 2 to start tomcat./usr/local/apache-tomcat-8.0.20/bin/startup. sh.
After the host is started, access through port 18080 of the host machine or through port 8080 of the Container
You can also use-v to start the shared host Directory: docker run-I-t-p 18080: 8080-v/usr/local/dockerData: /usr/local/docker linx/tomcat
Mount/usr/local/dockerData of the host to the/usr/local/docker directory of the Container for data sharing.
After modifying the container, you can save the image for future use.
1 docker commit containerID linx/tomcat3
Save container containerID as an image
Save container containerID as an image
First Article address: Solinx
Http://www.solinx.co/archives/152