我运行启动 tomcat8 服务器的 docker 映像,但它没有启动 [英] I run the docker images which start tomcat8 server but it don't start

查看:67
本文介绍了我运行启动 tomcat8 服务器的 docker 映像,但它没有启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有从我的 docker 文件创建的 docker 映像.当我运行映像时,它能够运行 tomcat 服务器,然后命令提示符返回.这意味着该过程已终止,我认为容器已停止.因此,当我看到 http://localhost:8080 时,没有出现 tomcat 页面.所以我无法找到实际的问题.我实际上正在尝试构建自定义 java8、tomcat8 和 maven 作为环境,并且我想在该 tomcat 服务器中部署我的 maven 项目.Bellow 是创建镜像的 Dockerfile

从头开始来自 ubuntu:16.04运行 mkdir/opt/java8运行 mkdir/opt/tomcat8运行 mkdir/opt/maven3ENV JAVA_HOME/opt/java8ENV CATALINA_HOME/opt/tomcat8ENV M2_HOME/opt/maven3环境路径 $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$M2_HOME/bin添加 jdk1.8.0_112/opt/java8添加 apache-tomcat-8.0.38/opt/tomcat8添加 apache-maven-3.3.9/opt/maven3曝光 8080CMD ["startup.sh", "run"]

我把 java、tomcat、maven 的 3 个文件夹放在 Docker 文件附近,所以这些都被添加了.

现在,当我构建映像并运行映像时,会出现以下日志.

root@dhavalbhoot:/home/veni/Documents/dhaval_bhoot/docker_images/tomcat1#docker run -it -p 8080:8080 dhaval/tomcat:8.0.38

输出:

使用 CATALINA_BASE:/opt/tomcat8使用 CATALINA_HOME:/opt/tomcat8使用 CATALINA_TMPDIR:/opt/tomcat8/temp使用 JRE_HOME:/opt/java8使用类路径:#/opt/tomcat8/bin/bootstrap.jar:/opt/tomcat8/bin/tomcat-juli.jarTomcat 启动.root@dhavalbhoot:/home/veni/Documents/dhaval_bhoot/docker_images/tomcat1#

这样提示回来了,我在浏览器中检查 http://localhost:8080没有出现tomcat页面所以帮我解决问题.

解决方案

类似docker 官方 tomcat 镜像 (8.0.40) 运行:

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

使用 catalina.sh 在前台启动 tomcat:进程不会立即退出.
如果您的 tomcat 安装确实包含该脚本,您应该使用它或 startup.sh.

或者直接运行一个tomcat镜像进行测试:

$ docker run -it --rm -p 8080:8080 tomcat:8.0

<块引用>

您可以在浏览器中访问 http://container-ip:8080 进行测试

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"]

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

Output:

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#

This way the prompt come back and I check in browser http://localhost:8080 tomcat page not appear So help me solving the problem.

解决方案

A similar docker official tomcat image (8.0.40) runs:

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

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.

Or run directly a tomcat image for testing:

$ docker run -it --rm -p 8080:8080 tomcat:8.0

You can test it by visiting http://container-ip:8080 in a browser

这篇关于我运行启动 tomcat8 服务器的 docker 映像,但它没有启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆