docker 重启镜像没有了,我运行启动tomcat8服务器的docker镜像,但它没有启动

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.

解决方案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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值