0

maven-wrapper.jartomcat:8.0-alpine コンテナーでファイルを実行しようとしている docker は初めてです。次の Web サイトでいくつかの手順に従いますhttps://medium.com/@pra4mesh/deploy-war-in-docker-tomcat-container-b52a3baea448 違いは、.jar ファイルを使用しているときに .war を使用することです。この情報が役に立つかどうかはわかりませんが、 https://start.spring.io/を使用したプロジェクトの自動生成です。

これがイメージを構築するための私の Dockerfile です (正直なところ、Dockerfile などと呼ばれるものが何であるかわかりません)。

FROM tomcat:8.0-alpine

LABEL maintainer="deepak@softwareyoga.com"

ADD maven-wrapper.jar /usr/local/tomcat/webapps/

EXPOSE 8080

CMD ["catalina.sh", "run"]

次のコマンドを使用してイメージをビルドする場合に注意してください。

\Desktop\try>docker build .
Sending build context to Docker daemon  53.76kB
Step 1/5 : FROM tomcat:8.0-alpine
8.0-alpine: Pulling from library/tomcat
4fe2ade4980c: Already exists
6fc58a8d4ae4: Already exists
7d9bd64c803b: Already exists
a22aedc5ac11: Already exists
5bde63ae3587: Already exists
69cb0c9b940a: Already exists
Digest: sha256:d02a16c0147fcae13d812fa670a4b3c9944f5328b10a5a463ad697d2aa5bb063
Status: Downloaded newer image for tomcat:8.0-alpine
 ---> 624fb61775c3
Step 2/5 : LABEL maintainer="deepak@softwareyoga.com"
 ---> Running in 1d725bda89d9
Removing intermediate container 1d725bda89d9
 ---> 11b904dae739
Step 3/5 : ADD maven-wrapper.jar /usr/local/tomcat/webapps/
 ---> ed694b383b75
Step 4/5 : EXPOSE 8080
 ---> Running in 2dc19f215bc7
Removing intermediate container 2dc19f215bc7
 ---> 59981a644862
Step 5/5 : CMD ["catalina.sh", "run"]
 ---> Running in 08f6b5d8d632
Removing intermediate container 08f6b5d8d632
 ---> c8576389fd76
Successfully built c8576389fd76
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double-check and reset permissions for sensitive files and directories.

「正常に構築された」それは機能し、イメージを生成します

\Desktop\try>docker images REPOSITORY TAG IMAGE ID CREATED SIZE c8576389fd76 6 分前 147MB tomcat 8.0-alpine 624fb61775c3 14 ヶ月前 147MB

my jar file name maven-wrapper.jar 
and exist in same folder with Dockerfile
>Desktop\try>dir
11/08/2019  10:33 PM    <DIR>          .
11/08/2019  10:33 PM    <DIR>          ..
11/08/2019  11:24 PM               301 Dockerfile
11/08/2019  05:27 PM            50,710 maven-wrapper.jar
               2 File(s)         51,011 bytes
               2 Dir(s)  269,240,381,440 bytes free 

\Desktop\try>docker container run -it --publish 8081:8080 c8576389fd76
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-1.7-openjdk/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
08-Nov-2019 21:52:57.955 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.53
08-Nov-2019 21:52:57.958 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 29 2018 14:42:45 UTC
08-Nov-2019 21:52:57.959 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.53.0
08-Nov-2019 21:52:57.962 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
08-Nov-2019 21:52:57.964 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            4.9.184-linuxkit
08-Nov-2019 21:52:57.965 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
08-Nov-2019 21:52:57.966 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-1.7-openjdk/jre
08-Nov-2019 21:52:57.966 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.7.0_181-b01
08-Nov-2019 21:52:57.967 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
08-Nov-2019 21:52:57.967 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
08-Nov-2019 21:52:57.968 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
08-Nov-2019 21:52:57.969 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
08-Nov-2019 21:52:57.970 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
08-Nov-2019 21:52:57.971 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
08-Nov-2019 21:52:57.976 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
08-Nov-2019 21:52:57.979 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
08-Nov-2019 21:52:57.981 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
08-Nov-2019 21:52:57.983 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
08-Nov-2019 21:52:57.983 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
08-Nov-2019 21:52:57.984 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.17 using APR version 1.6.3.
08-Nov-2019 21:52:57.985 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
08-Nov-2019 21:52:57.991 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2o  27 Mar 2018)
08-Nov-2019 21:52:58.082 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
08-Nov-2019 21:52:58.092 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
08-Nov-2019 21:52:58.095 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 766 ms
08-Nov-2019 21:52:58.127 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
08-Nov-2019 21:52:58.127 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.53
08-Nov-2019 21:52:58.151 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/manager
08-Nov-2019 21:52:58.907 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/manager has finished in 756 ms
08-Nov-2019 21:52:58.908 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/host-manager
08-Nov-2019 21:52:59.001 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/host-manager has finished in 93 ms
08-Nov-2019 21:52:59.002 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/examples
08-Nov-2019 21:52:59.427 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/examples has finished in 425 ms
08-Nov-2019 21:52:59.428 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/ROOT
08-Nov-2019 21:52:59.455 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/ROOT has finished in 27 ms
08-Nov-2019 21:52:59.456 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/tomcat/webapps/docs
08-Nov-2019 21:52:59.482 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/tomcat/webapps/docs has finished in 26 ms
08-Nov-2019 21:52:59.489 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
08-Nov-2019 21:52:59.504 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
08-Nov-2019 21:52:59.509 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1413 ms

http://localhost:8081 に移動すると、Tomcat サーバーのデフォルト ページが表示されました http://localhost:8081/maven-wrapper "HTTP Status 404 – Not Found any help ?!!

4

1 に答える 1