初始情况
在Ubuntu(14.04/14.10)中,我运行了以下命令:
apt-get update && apt-get install tomcat7
service tomcat7 start
一方面,我在VirtualBox虚拟机上尝试了这个操作,tomcat7如预期般启动:
vagrant init hashicorp/precise32
vagrant up
另一方面,我在Docker容器中尝试了这个操作,如下所示启动:
sudo docker run -it --name tomcattest ubuntu bash
问题
执行"service tomcat7 start"命令时会输出[fail]。尽管Tomcat正在运行,但"/var/log/tomcat7/catalina.out"显示如下内容:
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
Apr 16, 2015 5:52:40 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 16, 2015 5:52:40 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 514 ms
Apr 16, 2015 5:52:41 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 16, 2015 5:52:41 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.52 (Ubuntu)
Apr 16, 2015 5:52:41 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Apr 16, 2015 5:52:42 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 16, 2015 5:52:42 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1150 ms
搜索到解释
有人能解释一下不同的行为,并告诉我是否可以通过apt-get在Docker容器内轻松安装Tomcat7而不会出现警告吗?
Dockerfile
本身中修复它的方法? - Arpit Aggarwaldocker run
还没有这样的命令行参数。请参阅文档。 - Thomas Steinbachdocker build
的参考文档。请查看docker run
的文档。 - Thomas Steinbach