First, create the Dockerfile file:
Create the Dockerfile file and download the JDK with Tomcat in the Dockerfile directory.
Dockerfile File Contents:
1From Ubuntu:14.102 Maintainer Linx3 4 #把java与tomcat添加到容器中5ADD jdk-8u31-linux-x64.Tar. gz/usr/local/6ADD apache-tomcat-8.0. -.Tar. gz/usr/local/7 8 #配置java与tomcat环境变量9ENV Java_home/usr/local/jdk1.8. 0_31TenENV CLASSPATH $JAVA _home/lib/dt.jar: $JAVA _home/lib/Tools.jar OneENV catalina_home/usr/local/apache-tomcat-8.0. - AENV catalina_base/usr/local/apache-tomcat-8.0. - -ENV PATH $PATH: $JAVA _home/bin: $CATALINA _home/lib: $CATALINA _home/bin - the #容器运行时监听的端口 -EXPOSE8080
Second, create the image
1 perform docker build–t linx/tomcat. Command
Third, enter the container:
1 Execute 18080:8080 linx/2 start Tomcat ./usr/local/apache-tomcat- 8.0. /bin/startup. SH
can be accessed via the host's 18080 port or via the container 8080 port after boot
You can also start a shared host directory using-V: Docker run–i–t–p 18080:8080–v/usr/local/dockerdata:/usr/local/docker Linx/tomcat
Mount the host's/usr/local/dockerdata to the container/usr/local/docker directory for shared data
modifications to the container can be used to save the image for later use
1 Docker commit Containerid LINX/TOMCAT3
Save the container Containerid as an image
Save the container Containerid as an image
Article starting address: Solinx
http://www.solinx.co/archives/152
Create a docker image, initialize the JDK8 with the Tomcat environment