我运行启动tomcat8服务器的docker镜像,但它没有启动 [英] I run the docker images which start tomcat8 server but it don't start
问题描述
我有docker图像,我是用docker文件创建的。当我运行图像时,它能够运行tomcat服务器,然后命令提示符返回。这意味着该过程终止,我认为容器停止。因此,当我看到 http:// localhost:8080 时,不会显示tomcat页面。所以我无法找到实际的问题所在。我实际上试图构建自定义java8,tomcat8和maven作为环境,我想在该tomcat服务器中部署我的maven项目。
Bellow是用于创建图像的Dockerfile
I have docker image which I create from my docker file. When I run the image it has able to run the tomcat server then the command prompt come back. That mean the process is terminated and I think the container stops. So when I see http://localhost:8080 no tomcat page is appear. So I am not able find actual what is the problem. I am actually trying to to build custom java8, tomcat8 and maven as environment and I want to deploy my maven project in that tomcat server. Bellow is the Dockerfile to create image
FROM scratch
FROM ubuntu:16.04
RUN mkdir /opt/java8
RUN mkdir /opt/tomcat8
RUN mkdir /opt/maven3
ENV JAVA_HOME /opt/java8
ENV CATALINA_HOME /opt/tomcat8
ENV M2_HOME /opt/maven3
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$M2_HOME/bin
ADD jdk1.8.0_112 /opt/java8
ADD apache-tomcat-8.0.38 /opt/tomcat8
ADD apache-maven-3.3.9 /opt/maven3
EXPOSE 8080
CMD ["startup.sh", "run"]
我把3,java文件夹,tomcat,maven附近的Docker文件,所以添加它们。
I put 3 folder of java, tomcat, maven near Docker file so those are added.
现在,当我构建图像并运行图像时,会出现波纹管日志。
Now when I build the image and run the image the bellow log appear.
root@dhavalbhoot:/home/veni/Documents/dhaval_bhoot/docker_images/tomcat1#
docker run -it -p 8080:8080 dhaval/tomcat:8.0.38
输出:
Using CATALINA_BASE: /opt/tomcat8
Using CATALINA_HOME: /opt/tomcat8
Using CATALINA_TMPDIR: /opt/tomcat8/temp
Using JRE_HOME: /opt/java8
Using CLASSPATH:
\#/opt/tomcat8/bin/bootstrap.jar:/opt/tomcat8/bin/tomcat-juli.jar
Tomcat started.
root@dhavalbhoot:/home/veni/Documents/dhaval_bhoot/docker_images/tomcat1#
这样提示就会回来,我在浏览器中查看 http:// localhost:8080
tomcat页面没有出现
所以帮我解决问题。
This way the prompt come back and I check in browser http://localhost:8080 tomcat page not appear So help me solving the problem.
推荐答案
类似的 docker官方tomcat图像(8.0.40)运行:
CMD ["catalina.sh", "run"]
使用 catalina.sh在前台启动tomcat :流程赢了t立即退出。
如果tomcat安装包含该脚本,则应使用它或 startup.sh
。
With catalina.sh made to start tomcat in the foreground: the process won't exit immediately.
If you tomcat installation does include that script, you should use it instead or startup.sh
.
或直接运行tomcat图像进行测试:
Or run directly a tomcat image for testing:
$ docker run -it --rm -p 8080:8080 tomcat:8.0
您可以访问进行测试http:// container-ip:8080 在浏览器中
这篇关于我运行启动tomcat8服务器的docker镜像,但它没有启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!