更新时间:2023-01-18 07:51:01
我尝试了你的步骤,并且能够很好地运行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/