我需要在 docker 容器中的 Tomcat 上收集一个简单的 Java 应用程序,但在启动后我们有错误:
HTTP Status 404 - /docker-test-02-1.0-SNAPSHOT
type Status report
message /docker-test-02-1.0-SNAPSHOT
description The requested resource is not available.
Apache Tomcat/8.0.41
项目:
Dockerfile :
FROM tomcat:8.0.41-jre8
MAINTAINER Sergii D
# fixed path for copying
COPY docker-test-02-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.war
# Routine for me - optional for your case
EXPOSE 8080
# And run tomcat
CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]
docker build -t yourname .
docker run --rm -it -p 8080:8080 yourname
user@pc MINGW64 /d/docker-dir
$ docker build -t hello-docker-01 .
Sending build context to Docker daemon 103.4 kB
Step 1/5 : FROM tomcat:8.0.41-jre8
---> f1fc1ce9e0ab
Step 2/5 : MAINTAINER Sergii D
---> Using cache
---> 538a59db8c27
Step 3/5 : COPY docker-test-02-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.w
ar
---> 3fdcd3813c43
Removing intermediate container af956ac954a9
Step 4/5 : EXPOSE 8080
---> Running in 7bef72073fa8
---> bc5e2f1a9bf1
Removing intermediate container 7bef72073fa8
Step 5/5 : CMD /usr/local/tomcat/bin/catalina.sh run
---> Running in c51d453b3752
---> f742d6cd3cf5
Removing intermediate container c51d453b3752
Successfully built f742d6cd3cf5
SECURITY WARNING: You are building a Docker image from Windows against a non-Win
dows Docker host. All files and directories added to build context will have '-r
wxr-xr-x' permissions. It is recommended to double check and reset permissions f
or sensitive files and directories.
user@pc MINGW64 /d/docker-dir
$ docker --rm -it -p 8080:8080 hello-docker-01
flag provided but not defined: --rm
See 'C:\Program Files\Docker Toolbox\docker.exe --help'.
user@pc MINGW64 /d/docker-dir
$ docker run --rm -it -p 8080:8080 hello-docker-01
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-8-openjdk-amd64/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin
/tomcat-juli.jar
31-Jan-2017 14:14:10.330 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Server version: Apache Tomcat/8.0.41
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Server built: Jan 18 2017 22:19:39 UTC
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Server number: 8.0.41.0
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log OS Name: Linux
31-Jan-2017 14:14:10.344 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log OS Version: 4.4.43-boot2docker
31-Jan-2017 14:14:10.345 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Architecture: amd64
31-Jan-2017 14:14:10.346 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Java Home: /usr/lib/jvm/java-8-openjdk-amd64/jre
31-Jan-2017 14:14:10.346 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log JVM Version: 1.8.0_111-8u111-b14-2~bpo8+1-b14
31-Jan-2017 14:14:10.347 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log JVM Vendor: Oracle Corporation
31-Jan-2017 14:14:10.347 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log CATALINA_BASE: /usr/local/tomcat
31-Jan-2017 14:14:10.347 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log CATALINA_HOME: /usr/local/tomcat
31-Jan-2017 14:14:10.348 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tom
cat/conf/logging.properties
31-Jan-2017 14:14:10.348 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.Cl
assLoaderLogManager
31-Jan-2017 14:14:10.348 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
31-Jan-2017 14:14:10.349 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catali
na.webresources
31-Jan-2017 14:14:10.349 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.endorsed.dirs=/usr/local/tomcat/endorse
d
31-Jan-2017 14:14:10.349 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
31-Jan-2017 14:14:10.350 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
31-Jan-2017 14:14:10.350 INFO [main] org.apache.catalina.startup.VersionLoggerLi
stener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
31-Jan-2017 14:14:10.350 INFO [main] org.apache.catalina.core.AprLifecycleListen
er.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.10 using APR
version 1.5.1.
31-Jan-2017 14:14:10.351 INFO [main] org.apache.catalina.core.AprLifecycleListen
er.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters
[false], random [true].
31-Jan-2017 14:14:10.381 INFO [main] org.apache.catalina.core.AprLifecycleListen
er.initializeSSL OpenSSL successfully initialized (OpenSSL 1.1.0c 10 Nov 2016)
31-Jan-2017 14:14:10.748 INFO [main] org.apache.coyote.AbstractProtocol.init Ini
tializing ProtocolHandler ["http-apr-8080"]
31-Jan-2017 14:14:10.769 INFO [main] org.apache.coyote.AbstractProtocol.init Ini
tializing ProtocolHandler ["ajp-apr-8009"]
31-Jan-2017 14:14:10.772 INFO [main] org.apache.catalina.startup.Catalina.load I
nitialization processed in 2074 ms
31-Jan-2017 14:14:10.860 INFO [main] org.apache.catalina.core.StandardService.st
artInternal Starting service Catalina
31-Jan-2017 14:14:10.861 INFO [main] org.apache.catalina.core.StandardEngine.sta
rtInternal Starting Servlet Engine: Apache Tomcat/8.0.41
31-Jan-2017 14:14:10.958 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deploying web application archive /usr/local/tomcat/webap
ps/ROOT.war
31-Jan-2017 14:14:11.884 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployWAR Deployment of web application archive /usr/local/tomcat/w
ebapps/ROOT.war has finished in 921 ms
31-Jan-2017 14:14:11.893 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/manager
31-Jan-2017 14:14:11.988 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/manager has finished in 95 ms
31-Jan-2017 14:14:11.988 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/host-manager
31-Jan-2017 14:14:12.051 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/host-manager has finished in 63 ms
31-Jan-2017 14:14:12.052 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/docs
31-Jan-2017 14:14:12.093 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/docs has finished in 41 ms
31-Jan-2017 14:14:12.101 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deploying web application directory /usr/local/tomc
at/webapps/examples
31-Jan-2017 14:14:12.812 INFO [localhost-startStop-1] org.apache.catalina.startu
p.HostConfig.deployDirectory Deployment of web application directory /usr/local/
tomcat/webapps/examples has finished in 712 ms
31-Jan-2017 14:14:12.823 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["http-apr-8080"]
31-Jan-2017 14:14:12.839 INFO [main] org.apache.coyote.AbstractProtocol.start St
arting ProtocolHandler ["ajp-apr-8009"]
31-Jan-2017 14:14:12.844 INFO [main] org.apache.catalina.startup.Catalina.start
Server startup in 2071 ms
http://192.168.99.100:8080/docker-test-02-1.0-SNAPSHOT
我看到错误The requested resource is not available.
我该如何解决?
PS:如果打开192.168.99.100:8080会有样本TomCat页面,所以TomCat都可以 .PNG
答案 0 :(得分:0)
您正在将war文件复制为Root。在docker文件中复制它时发生战争。将其复制为/ usr / local / tomcat / webapps /。或者尝试上下文ROOT。