Tomcat7在debian中:wheezy Docker实例无法启动 [英] Tomcat7 in debian:wheezy Docker instance fails to start

查看:150
本文介绍了Tomcat7在debian中:wheezy Docker实例无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google的debian镜像(google / debian:wheezy)第一次构建Docker镜像,在其上设置OpenJDK7并尝试设置Tomcat7。

  docker pull google / debian:wheezy 
docker run -i -t google / debian:wheezy bash
/ pre>

一旦我在bash,我安装openjdk与

  apt-get update 
apt-get install openjdk-7-jre

而我得到一个错误,我必须运行

  apt-get update --fix-missing 
apt-get安装openjdk-7-jre
apt-get install tomcat7

安装Tomcat7后,尝试开始使用

  /etc/init.d/tomcat7 start 
/ pre>

其中给我以下错误:

  [失败]启动Tomcat servlet引擎:tomcat7失败! 

我显然做错了,我在Debian Docker上得到完全相同的行为安装和我的OSX Docker安装(至少它是一致的,这有点令人印象深刻!)



查看/var/log/catalina.out不显示任何错误, localhost日志。



我用一个正常的debian进行了同样的处理:wheezy图像并且得到完全相同的失败而没有任何错误。
任何想法,我正在拧紧?

解决方案

我尝试了你的步骤,能够运行tomcat 。我没有得到apt-get的问题,所以现在需要使用 apt-get update --fix-missing 。我甚至从init.d脚本启动tomcat,它的工作。



我的猜测是,你有一些网络问题,或者Debian的存储库有一些问题,但是他们已经修复了。



无论如何,您应该注意,只要指定的命令正在运行,容器就会运行。这意味着你应该在前台运行tomcat,或者以另一种方式确保相同的东西。您可以查看此答案了解某些选项。





我已经创建了一个 Dockerfile 来测试这个。这里是:

  FROM google / debian:wheezy 

运行apt-get update
运行apt-get install -y openjdk-7-jre tomcat7

添加run.sh /root/run.sh
运行chmod + x /root/run.sh

EXPOSE 8080

CMD [/root/run.sh]

这里是它使用的 run.sh 脚本:

 #!/ bin / bash 

/etc/init.d/tomcat7 start

#只要脚本运行,容器就会运行,这就是为什么
#我们需要一些长久的东西
exec tail -f /var/log/tomcat7/catalina.out

以下是一个示例构建和运行会话:

  $ docker build -t tomcat7-test。 
$ docker run -d -p 8080:8080 tomcat7-test

现在你应该能够看到tomcat的It works!页面 http:// localhost:8080 /


I'm trying to build a docker image for the first time using a debian image from Google (google/debian:wheezy), setting up OpenJDK7 on it and trying to setup Tomcat7.

docker pull google/debian:wheezy
docker run -i -t google/debian:wheezy bash

Once I'm in bash, I install openjdk with

apt-get update
apt-get install openjdk-7-jre

After a while, I get an error and I must run

 apt-get update --fix-missing
 apt-get install openjdk-7-jre
 apt-get install tomcat7

After Tomcat7 is installed, I try to start it with

/etc/init.d/tomcat7 start

Which gives me the following error:

[FAIL] Starting Tomcat servlet engine: tomcat7 failed!

I'm obviously doing something wrong, I'm getting the exact same behaviour on both my Debian Docker installation and my OSX Docker installation (at least it's consistent, that's kinda impressive!)

Looking in /var/log/catalina.out doesn't show any errors, neither does the localhost logs.

I've followed the same process with a normal debian:wheezy image and getting exactly the same failure without any errors. Any idea where I'm screwing up?

解决方案

I tried your steps and was able to run tomcat just fine. I didn't get the problem with apt-get, so now apt-get update --fix-missing was required. I even started tomcat from the init.d script and it worked.

My guess is, that either you had some network problems, or there were some problems with Debian's repositories, but they got fixed.

In any case you should note, that the container is running as long as the specified command is running. That means, that you should either run tomcat in the foreground or ensure the same thing in another way. You can check this answer for some options.

[EDIT]

I've created a Dockerfile to test this. Here it is:

FROM google/debian:wheezy

RUN apt-get update
RUN apt-get install -y openjdk-7-jre tomcat7

ADD run.sh /root/run.sh
RUN chmod +x /root/run.sh

EXPOSE 8080

CMD ["/root/run.sh"]

And here is the run.sh script that it uses:

#!/bin/bash

/etc/init.d/tomcat7 start

# The container will run as long as the script is running, that's why
# we need something long-lived here
exec tail -f /var/log/tomcat7/catalina.out

Here is a sample build and run session:

$ docker build -t tomcat7-test .
$ docker run -d -p 8080:8080 tomcat7-test

Now you should be able to see tomcat's "It works !" page on http://localhost:8080/

这篇关于Tomcat7在debian中:wheezy Docker实例无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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