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

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

问题描述

我第一次尝试使用来自 Google (google/debian:wheezy) 的 debian 映像构建 docker 映像,在其上设置 OpenJDK7 并尝试设置 Tomcat7.

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

一旦我在 bash 中,我会安装 openjdk

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

Tomcat7安装后,我尝试用它启动

After Tomcat7 is installed, I try to start it with

/etc/init.d/tomcat7 start

这给了我以下错误:

[FAIL] Starting Tomcat servlet engine: tomcat7 failed!

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

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!)

查看/var/log/catalina.out 没有显示任何错误,本地主机日志也没有.

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

我对正常的 debian:wheezy 映像执行了相同的过程,并得到完全相同的失败而没有任何错误.知道我在哪里搞砸了吗?

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?

推荐答案

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

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.

我的猜测是,要么是您遇到了一些网络问题,要么是 Debian 的存储库出现了一些问题,但它们都得到了修复.

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

在任何情况下你都应该注意,只要指定的命令正在运行,容器就会运行.这意味着,您应该在前台运行 tomcat 或以另一种方式确保相同的事情.您可以查看this answer了解一些选项.

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.

我创建了一个 Dockerfile 来测试它.这里是:

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

这是它使用的 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

现在您应该可以看到 tomcat 的It works!"http://localhost:8080/

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

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

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