Create a docker image and initialize the jdk8 and tomcat environments.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.