docker linux centos 安装 tomcat
程序员文章站
2024-03-25 13:34:28
...
37.4 创建docker centos-ssh-root-java-tomcat
37.4.0 前提 拥有一个 centos-ssh-root-java
37.4.1 编辑 dockerfile
############################################
# version:apache-tomcat-7.0.75
# desc : 当前版本安装的7.0.75
############################################
# 设置继承自我们创建的 tools 镜像
FROM curiousby/centos-ssh-root-java:original
# 下面是一些创建者的基本信息
MAINTAINER baoyou aaa@qq.com
# 复制 apache-tomcat-7.0.75.tar.gz 文件到镜像中
ADD apache-tomcat-7.0.75.tar.gz /usr/local/
# 设置软连接
RUN ln -s /usr/local/apache-tomcat-7.0.75 /usr/local/tomcat
# 设置 tomcat 的环境变量,若读者有其他的环境变量需要设置
ENV CATALINA_HOME /usr/local/apache-tomcat-7.0.75
# 容器需要开放Tomcat 8080端口
EXPOSE 8080
COPY autorun.sh /usr/local/tomcat/bin/autorun.sh
RUN chmod u+x /usr/local/tomcat/bin/autorun.sh
# 自启动
CMD ["/usr/local/tomcat/bin/autorun.sh"]
37.4.2 编辑自动启动脚本
#!/bin/bash
source ~/.bashrc
sh /usr/local/tomcat/bin/catalina.sh run
37.4.3 执行命令
cd centos-ssh-root-java
cp ../apache-tomcat-7.0.75.tar.gz .
vim Dockerfile
tar -xf apache-tomcat-7.0.75.tar.gz
vim apache-tomcat-7.0.75.tar.gz/bin/catalina.sh
添加代码
export JAVA_HOME=/usr/local/jdk1.7.0_79
export JRE_HOME=/usr/local/jdk1.7.0_79/jre
export CATALINA_HOME=/usr/local/apache-tomcat-7.0.75
export CATALINA_BASE=/usr/local/apache-tomcat-7.0.75
export CATALINA_TMPDIR=/usr/local/apache-tomcat-7.0.75/temp
cp apache-tomcat-7.0.75.tar.gz/bin/catalina.sh .
vim autorun.sh
#!/bin/bash
source ~/.bashrc
sh /usr/local/tomcat/bin/catalina.sh run
docker build -t "curiousby/centos-ssh-root-java-tomcat:original" .
docker run -d -p 8080:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8081:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8082:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
37.4.4 运行 build 日志
#build 运行日志
[aaa@qq.com centos-ssh-root-java-tomcat]# docker build -t curiousby/centos-ssh-root-java-tomcat:original .
Sending build context to Docker daemon 8.967MB
Step 1/9 : FROM curiousby/centos-ssh-root-java:original
---> b927a708d880
Step 2/9 : MAINTAINER baoyou aaa@qq.com
---> Running in c714e382a89f
---> 8843e826df75
Removing intermediate container c714e382a89f
Step 3/9 : ADD apache-tomcat-7.0.75.tar.gz /usr/local/
---> d658ff1a2ba5
Removing intermediate container efb719168d48
Step 4/9 : RUN ln -s /usr/local/apache-tomcat-7.0.75 /usr/local/tomcat
---> Running in 799eb96d5d2a
---> 96623ac69cbd
Removing intermediate container 799eb96d5d2a
Step 5/9 : ENV CATALINA_HOME /usr/local/apache-tomcat-7.0.75
---> Running in c59375c73a1d
---> b707eae87825
Removing intermediate container c59375c73a1d
Step 6/9 : EXPOSE 8080
---> Running in 482ebe032044
---> e52bb95bb46e
Removing intermediate container 482ebe032044
Step 7/9 : COPY autorun.sh /usr/local/tomcat/bin/autorun.sh
---> 3cfd1c86bccf
Removing intermediate container c1aa90cb1121
Step 8/9 : RUN chmod u+x /usr/local/tomcat/bin/autorun.sh
---> Running in 4b3ccdeb4f53
---> 54988bebb05c
Removing intermediate container 4b3ccdeb4f53
Step 9/9 : CMD /usr/local/tomcat/bin/autorun.sh
---> Running in c1235f2f90e2
---> 7dd208c74262
Removing intermediate container c1235f2f90e2
Successfully built 7dd208c74262
Successfully tagged curiousby/centos-ssh-root-java-tomcat:original
[aaa@qq.com centos-ssh-root-java-tomcat]#
37.4.5 运行 run 结果
docker run -d -p 8080:8080 curiousby/centos-ssh-root-java-tomcat:original
docker run -d -p 8081:8080 curiousby/centos-ssh-root-java-tomcat:original
docker run -d -p 8082:8080 curiousby/centos-ssh-root-java-tomcat:original
docker run -d -p 8080:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8081:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
docker run -d -p 8082:8080 curiousby/centos-ssh-root-java-tomcat:original -v /docker/tomcat1/logs/:/usr/local/tomcat/logs
37.4.6运行 run web 页面
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。
个人主页:http://knight-black-bob.iteye.com/
谢谢您的赞助,我会做的更好!
上一篇: 自建博客es找不到索引
下一篇: pip默认环境切换
推荐阅读
-
Docker详细安装Tomcat
-
docker linux centos 安装 tomcat
-
【Linux】虚拟机CentOS 7 安装jdk_1.7 rpm版本
-
CentOS/Linux 下设置 tomcat开机自启动 tomcat
-
CentOS/Linux 下设置 tomcat开机自启动 tomcat
-
Linux\CentOS MySql 安装与配置
-
centos7安装和配置jdk+tomcat
-
Linux下下载,安装,配置Tomcat TomcatLinuxApacheJDKWeb
-
Linux下下载,安装,配置Tomcat TomcatLinuxApacheJDKWeb
-
CentOS7中Docker安装mysql主从复制