我用docker创建镜像
dockerfile文件内容如下:
FROM daocloud.io/library/centos
MAINTAINER lun9090 <643812461@qq.com>
ADD apache-tomcat-6.0.41 /opt/apache-tomcat-6.0.41
RUN cd /opt/ && mv apache-tomcat-6.0.41 tomcat
ADD jdk-6u45-linux-x64.bin /opt/
RUN cd /opt && chmod +x jdk-6u45-linux-x64.bin && ./jdk-6u45-linux-x64.bin && mv jdk1.6.0_45 jdk && rm jdk-6u45-linux-x64.bin
ADD web-server /opt/tomcat/webapps/web-server
ENV JAVA_HOME /opt/jdk
ENV JRE_HOME $JAVA_HOME/jre
ENV CLASSPATH .:$JAVA_HOME/lib:$JRE_HOME/lib
ENV PATH $PATH:$JAVA_HOME/bin
CMD /opt/tomcat/bin/catalina.sh run
web-server是基于uap开发的应用,总是加载不上,启动容器后的log日志如下:
[root@docker1 uap]# docker logs -f eb9108ca79e0
Dec 8, 2015 7:29:27 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /opt/jdk/jre/lib/amd64/server:/opt/jdk/jre/lib/amd64:/opt/jdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Dec 8, 2015 7:29:28 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Dec 8, 2015 7:29:28 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1894 ms
Dec 8, 2015 7:29:28 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Dec 8, 2015 7:29:28 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.41
Dec 8, 2015 7:29:28 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Dec 8, 2015 7:29:29 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Dec 8, 2015 7:29:29 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Dec 8, 2015 7:29:30 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory host-manager
Dec 8, 2015 7:29:30 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory manager
Dec 8, 2015 7:29:30 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory sguap-server
Dec 8, 2015 7:29:30 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Dec 8, 2015 7:29:30 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Dec 8, 2015 7:29:30 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/18 config=null
Dec 8, 2015 7:29:30 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2501 ms
这是怎么回事啊?
其实我强烈建议你用spring boot之类的东西把容器和你的war打包成一个可以直接运行的jar,然后你就不烦恼了。
@jokester 这个服务是基于osgi的动态服务, 在容器中能够正常启动,但是不知道为啥封装好了就不能启动了,无法加载osgi
dockerfile中也没指定端口啊
你启动的时候做端口映射了么?
docker inspect看一下容器的ip
然后访问一下ip:8080试试撒