Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using docker to build tomcat environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. create a directory

[root@ticent docker]#mkdir /home/docker

2. Download tomcat

[root@ticent docker]#wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.0.45/bin/apache-tomcat-8.0.44.tar.gz

3. Download jdk

[root@ticent docker]# wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz

4. Extract to current directory

5. Edit Dockerfile

[root@ticent docker]#vi Dockerfile

Click here to fold or open

FROM centos:latest

#install jdk

ADD jdk1.8.0_131 /opt/jdk8

ENV JAVA_HOME /opt/jdk8

ENV PATH $PATH:$JAVA_HOME/bin

RUN mkdir -p "$JAVA_HOME"

#install tomcat

ADD tomcat8 /opt/tomcat8

ENV CATALINA_HOME /opt/tomcat8

ENV PATH $CATALINA_HOME/bin:$PATH

RUN mkdir -p "$CATALINA_HOME"

WORKDIR $CATALINA_HOME

EXPOSE 8080

CMD ["catalina.sh", "run"]

6. Local centos mirror, here centos:latest

7. build images

[root@ticent docker]# docker build -t tomcat8 .

8. Start, tomcat port mapped to 18080

[root@ticent docker]# docker run -d -p 18080:8080 tomcat8

9. View docker progress

[root@ticent docker]# docker ps

10. Visit tomcat

11. into the container

docker exec -it 65f238010b2c /bin/bash

12. In this article, we use centos mirror to manually build jdk and tomcat into the mirror, which makes it easier to customize the runtime environment.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report