Build a docker image to build Tomcat9.0 mirroring (RPM One-click Install Java Environment)

Source: Internet
Author: User
Tags docker hub docker run

Build a docker image to build Tomcat9.0 mirroring (RPM One-click Install Java Environment)

Tomcat is a free, open source, lightweight Web server that is commonly used in small and medium-sized enterprises and where concurrent access is low, and is the first choice for developing and debugging JSP programs. The following is the way to create a dockerfile image with the Tomcat service using the Dockerfile file. (Note: The Java environment here is a one-button installation using RPM, and the small series created is a tomcat9.0 image)

Start the experiment directly below

    • Shutting down firewalls and SELinux
systemctl stop firewalld.servicesetenforce 0

    • Create a working directory
[[email protected] ~]# mkdir /root/tomcat
    • Unzip the tomcat9.0 package to the working directory
[[email protected] ~]# cd /root/tomcat/     //切换目录至工作目录[[email protected] tomcat]# cp /abc/tomcat/apache-tomcat-9.0.8.tar.gz ./    //复制本地的tomcat9.0软件包至工作目录[[email protected] tomcat]# cp /abc/tomcat/jdk-8u171-linux-x64.rpm ./     //复制本地的jdk的rpm包至工作目录[[email protected] tomcat]# tar xf apache-tomcat-9.0.8.tar.gz     //解压安装tomcat服务
    • Create a Dockerfile file

Vim Dockerfile

FROM centos       //基于基础镜像MAINTAINER this is tomcat image <chen>       //作者信息COPY jdk-8u171-linux-x64.rpm /usr/   //复制jdk的rpm包至容器的/usr/目录下WORKDIR /usr/     //切换目录至/usrRUN rpm -ivh jdk-8u171-linux-x64.rpm     //rpm一键安装jdk环境包ADD apache-tomcat-9.0.8 /usr/local/tomcat8      //解压安装tomcat9.0EXPOSE 8080       //指定端口8080

    • Creating Mirrors with Dockerfile
docker build -t tomcat:centos .      //这里别忽视最后有个小点哦!!!

    • Run the container and log in to the Web page to verify
[[email protected] tomcat]# docker run --name tomcat01 -p 80:8080 -it tomcat:centos /bin/bash       //映射本地的80端口到容器的8080端口[[email protected] usr]# cd /usr/local/tomcat8/bin/      [[email protected] bin]# ./startup.sh Using CATALINA_BASE:   /usr/local/tomcat8Using CATALINA_HOME:   /usr/local/tomcat8Using CATALINA_TMPDIR: /usr/local/tomcat8/tempUsing JRE_HOME:        /usrUsing CLASSPATH:       /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jarTomcat started.

The Docker image with tomcat9.0 is generated, and then only the public repositories that are uploaded to the Docker hub can be downloaded for use, or they can be uploaded directly to a personal private repository for later use.

Build a docker image to build Tomcat9.0 mirroring (RPM One-click Install Java Environment)

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.