質問するログイン新規登録

質問編集履歴

10

説明を更新

2021/12/29 03:44

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -145,15 +145,8 @@
145
145
  ④作成したイメージからコンテナを作成し起動する
146
146
  docker run -it --publish 8080:8080 (Dockerユーザ名)/springboot-sample1:v1
147
147
  ```ここに言語を入力
148
- 28-Dec-2021 15:18:24.821 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.31] using APR version [1.7.0].
149
- 28-Dec-2021 15:18:24.822 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
150
- 28-Dec-2021 15:18:24.824 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k 25 Mar 2021]
151
- 28-Dec-2021 15:18:25.088 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
152
- 28-Dec-2021 15:18:25.106 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [454] milliseconds
153
- 28-Dec-2021 15:18:25.153 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
154
- 28-Dec-2021 15:18:25.153 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.14]
155
148
  28-Dec-2021 15:18:25.166 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/sample1.war]
156
- 28-Dec-2021 15:18:26.098 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
149
+
157
150
  28-Dec-2021 15:18:26.137 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/sample1.war] has finished in [971] ms
158
151
  28-Dec-2021 15:18:26.141 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
159
152
  28-Dec-2021 15:18:26.153 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [1047] milliseconds
@@ -201,10 +194,59 @@
201
194
  drwxr-x--- 3 root root 4096 Dec 29 01:52 org
202
195
  ```
203
196
 
197
+ orgフォルダの中身を確認。
198
+ ```
199
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# cd org/
200
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org# ls -la
201
+ total 12
202
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 .
203
+ drwxr-x--- 5 root root 4096 Dec 29 03:12 ..
204
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 springframework
205
+ root@cd66d6f2186c:/usr/local/tomcat/webapps/sample1/org#
206
+ root@cd66d6f2186c:/usr/local/tomcat/webapps/sample1/org# cd springframework/
207
+ root@cd66d6f2186c:/usr/local/tomcat/webapps/sample1/org/springframework# ls -la
208
+ total 12
209
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 .
210
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 ..
211
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 boot
212
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework#
213
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework# cd boot/
214
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework/boot# ls -la
215
+ total 12
216
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 .
217
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 ..
218
+ drwxr-x--- 7 root root 4096 Dec 29 03:12 loader
219
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework/boot# cd loader
220
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1/org/springframework/boot/loader# ls -la
221
+ total 124
222
+ drwxr-x--- 7 root root 4096 Dec 29 03:12 .
223
+ drwxr-x--- 3 root root 4096 Dec 29 03:12 ..
224
+ -rw-r----- 1 root root 5871 Feb 1 1980 ClassPathIndexFile.class
225
+ -rw-r----- 1 root root 6806 Feb 1 1980 ExecutableArchiveLauncher.class
226
+ -rw-r----- 1 root root 3966 Feb 1 1980 JarLauncher.class
227
+ -rw-r----- 1 root root 1483 Feb 1 1980 'LaunchedURLClassLoader$DefinePackageCallType.class'
228
+ -rw-r----- 1 root root 1535 Feb 1 1980 'LaunchedURLClassLoader$UseFastConnectionExceptionsEnumeration.class'
229
+ -rw-r----- 1 root root 11154 Feb 1 1980 LaunchedURLClassLoader.class
230
+ -rw-r----- 1 root root 5932 Feb 1 1980 Launcher.class
231
+ -rw-r----- 1 root root 1536 Feb 1 1980 MainMethodRunner.class
232
+ -rw-r----- 1 root root 266 Feb 1 1980 'PropertiesLauncher$1.class'
233
+ -rw-r----- 1 root root 1484 Feb 1 1980 'PropertiesLauncher$ArchiveEntryFilter.class'
234
+ -rw-r----- 1 root root 8128 Feb 1 1980 'PropertiesLauncher$ClassPathArchives.class'
235
+ -rw-r----- 1 root root 1953 Feb 1 1980 'PropertiesLauncher$PrefixMatchingArchiveFilter.class'
236
+ -rw-r----- 1 root root 18267 Feb 1 1980 PropertiesLauncher.class
237
+ -rw-r----- 1 root root 1750 Feb 1 1980 WarLauncher.class
238
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 archive
239
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 data
240
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 jar
241
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 jarmode
242
+ drwxr-x--- 2 root root 4096 Dec 29 03:12 util
243
+ ```
244
+
204
245
  curlコマンドでアクセス確認をするがTomcatの404が返却されてしまう
205
246
  ```ここに言語を入力
206
247
  root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# curl http://localhost:8080/sample1/sample/
207
- <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
248
+ <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} ~
249
+ <h3>Apache Tomcat/10.0.14</h3></body></html>
208
250
  ```
209
251
  コンテナの環境変数は以下のようになっています。
210
252
  ```ここに言語を入力
@@ -231,4 +273,6 @@
231
273
 
232
274
  ローカル環境(Spring Tool Suite4)ではページが表示できます。
233
275
  ![イメージ説明](f0af86a6f2cbfcbe36b8e395c5454681.png)
234
- ![イメージ説明](04f55890beafd5fa4b654b7eade9fca6.png)
276
+ ![イメージ説明](04f55890beafd5fa4b654b7eade9fca6.png)
277
+
278
+ orgフォルダが悪さをしているように見えますが、どうしてそのフォルダが出来てしまったのか分からず、解決方法は調査中です。

9

説明を更新

2021/12/29 03:44

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -212,7 +212,7 @@
212
212
  HOSTNAME=abd9ba51180a
213
213
  JAVA_HOME=/usr/local/openjdk-8
214
214
  GPG_KEYS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
215
- PWD=/
215
+ PWD=/usr/local/tomcat/webapps
216
216
  TOMCAT_SHA512=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
217
217
  TOMCAT_MAJOR=10
218
218
  HOME=/root

8

説明を更新

2021/12/29 03:15

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -226,6 +226,7 @@
226
226
  TOMCAT_VERSION=10.0.14
227
227
  JAVA_VERSION=8u312
228
228
  _=/usr/bin/printenv
229
+ OLDPWD=/usr/local/tomcat
229
230
  ```
230
231
 
231
232
  ローカル環境(Spring Tool Suite4)ではページが表示できます。

7

説明を更新

2021/12/29 03:14

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -206,6 +206,27 @@
206
206
  root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# curl http://localhost:8080/sample1/sample/
207
207
  <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
208
208
  ```
209
+ コンテナの環境変数は以下のようになっています。
210
+ ```ここに言語を入力
211
+ root@abd9ba51180a:/# printenv
212
+ HOSTNAME=abd9ba51180a
213
+ JAVA_HOME=/usr/local/openjdk-8
214
+ GPG_KEYS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
215
+ PWD=/
216
+ TOMCAT_SHA512=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
217
+ TOMCAT_MAJOR=10
218
+ HOME=/root
219
+ LANG=C.UTF-8
220
+ TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib
221
+ TERM=xterm
222
+ CATALINA_HOME=/usr/local/tomcat
223
+ SHLVL=1
224
+ LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib
225
+ PATH=/usr/local/tomcat/bin:/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/sbin
226
+ TOMCAT_VERSION=10.0.14
227
+ JAVA_VERSION=8u312
228
+ _=/usr/bin/printenv
229
+ ```
209
230
 
210
231
  ローカル環境(Spring Tool Suite4)ではページが表示できます。
211
232
  ![イメージ説明](f0af86a6f2cbfcbe36b8e395c5454681.png)

6

説明を更新

2021/12/29 03:07

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -205,4 +205,8 @@
205
205
  ```ここに言語を入力
206
206
  root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# curl http://localhost:8080/sample1/sample/
207
207
  <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
208
- ```
208
+ ```
209
+
210
+ ローカル環境(Spring Tool Suite4)ではページが表示できます。
211
+ ![イメージ説明](f0af86a6f2cbfcbe36b8e395c5454681.png)
212
+ ![イメージ説明](04f55890beafd5fa4b654b7eade9fca6.png)

5

説明の更新

2021/12/29 02:50

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,29 @@
2
2
  Tomcatにwarファイルを配置したイメージからDockerコンテナを起動してwarアプリケーションにアクセスできるかを確認しています。
3
3
  ブラウザからアクセスすると404が返ってきてしまいます。
4
4
 
5
+ /sample1/src/main/java/com/example/sample1/Sample1Application.java
6
+ ```java
7
+ package com.example.sample1;
8
+
9
+ import org.springframework.boot.SpringApplication;
10
+ import org.springframework.boot.autoconfigure.SpringBootApplication;
11
+ import org.springframework.boot.builder.SpringApplicationBuilder;
12
+ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
13
+
14
+ @SpringBootApplication
15
+ public class Sample1Application extends SpringBootServletInitializer {
16
+
17
+ public static void main(String[] args) {
18
+ SpringApplication.run(Sample1Application.class, args);
19
+ }
20
+
21
+ @Override
22
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
23
+ return builder.sources(Sample1Application.class);
24
+ }
25
+ }
26
+ ```
27
+
5
28
  /sample1/src/main/java/com/example/sample1/controller/SampleController.java
6
29
  ```java
7
30
  @RestController

4

タイトルと説明を修正

2021/12/29 02:19

投稿

Linkey
Linkey

スコア77

title CHANGED
@@ -1,1 +1,1 @@
1
- warアプリケーションのDockerコンテナにブラウザからアクセスできない
1
+ Spring BootのwarアプリケーションのDockerコンテナにブラウザからアクセスできない
body CHANGED
@@ -176,4 +176,10 @@
176
176
  drwxr-x--- 3 root root 4096 Dec 29 01:52 META-INF
177
177
  drwxr-x--- 5 root root 4096 Dec 29 01:52 WEB-INF
178
178
  drwxr-x--- 3 root root 4096 Dec 29 01:52 org
179
+ ```
180
+
181
+ curlコマンドでアクセス確認をするがTomcatの404が返却されてしまう
182
+ ```ここに言語を入力
183
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# curl http://localhost:8080/sample1/sample/
184
+ <!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;sample1&#47;sample&#47;] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/10.0.14</h3></body></html>
179
185
  ```

3

説明を修正

2021/12/29 02:15

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -151,14 +151,13 @@
151
151
  よろしくお願いいたします。
152
152
 
153
153
  --- 追記 ----
154
+ Dockerfileのcatalina.sh実行コマンドを以下のように修正して確認
155
+ CMD ["sh", "/usr/local/tomcat/bin/catalina.sh", "run"]
156
+
154
- 以下のコマンドでイメージからコンテナを作成して確認してみました。
157
+ Dockerイメージを作り直してから以下のコマンドでイメージからコンテナを作成
155
158
  docker container run -it -p 8080:8080 --name test (Dockerユーザ名)/springboot-sample1:v1 /bin/bash
156
159
 
157
- /usr/local/tomcat/webapps配下をみたところwarファイルしか配置されていなかったので手動でDockerfileに記載されている
158
- catalina.sh実行がうまくいっていなそうだったので手動でcatalina.shを実行
159
- sh /usr/local/tomcat/bin/catalina.sh start -security
160
-
161
- catalina.sh実施後の資材の配置状態は以下のような状態です。
160
+ 資材の配置状態は以下のような状態です。
162
161
  ```ここに言語を入力
163
162
  root@abd9ba51180a:/usr/local/tomcat/webapps# ls -la
164
163
  total 13096

2

説明を更新

2021/12/29 02:11

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -151,7 +151,14 @@
151
151
  よろしくお願いいたします。
152
152
 
153
153
  --- 追記 ----
154
+ 以下のコマンドでイメージからコンテナを作成して確認してみました。
155
+ docker container run -it -p 8080:8080 --name test (Dockerユーザ名)/springboot-sample1:v1 /bin/bash
156
+
157
+ /usr/local/tomcat/webapps配下をみたところwarファイルしか配置されていなかったので手動でDockerfileに記載されている
158
+ catalina.sh実行がうまくいっていなそうだったので手動でcatalina.shを実行
159
+ sh /usr/local/tomcat/bin/catalina.sh start -security
160
+
154
- 資材の配置状態は以下のような状態です。
161
+ catalina.sh実施後の資材の配置状態は以下のような状態です。
155
162
  ```ここに言語を入力
156
163
  root@abd9ba51180a:/usr/local/tomcat/webapps# ls -la
157
164
  total 13096

1

説明の更新

2021/12/29 02:01

投稿

Linkey
Linkey

スコア77

title CHANGED
File without changes
body CHANGED
@@ -148,4 +148,26 @@
148
148
 
149
149
  解決方法を探していますが、未だに解決ができていません。
150
150
  DockerとTomcatにお詳しい方がいましたらご回答いただけないでしょうか?
151
- よろしくお願いいたします。
151
+ よろしくお願いいたします。
152
+
153
+ --- 追記 ----
154
+ 資材の配置状態は以下のような状態です。
155
+ ```ここに言語を入力
156
+ root@abd9ba51180a:/usr/local/tomcat/webapps# ls -la
157
+ total 13096
158
+ drwxr-xr-x 1 root root 4096 Dec 29 01:45 .
159
+ drwxr-xr-x 1 root root 4096 Dec 22 17:10 ..
160
+ drwxr-x--- 4 root root 4096 Dec 29 01:45 sample1
161
+ -rwxr-xr-x 1 root root 13391545 Dec 29 01:43 sample1.war
162
+ ```
163
+
164
+ /usr/local/tomcat/webapps/sample1
165
+ ```ここに言語を入力
166
+ root@abd9ba51180a:/usr/local/tomcat/webapps/sample1# ls -la
167
+ total 20
168
+ drwxr-x--- 5 root root 4096 Dec 29 01:52 .
169
+ drwxr-xr-x 1 root root 4096 Dec 29 01:52 ..
170
+ drwxr-x--- 3 root root 4096 Dec 29 01:52 META-INF
171
+ drwxr-x--- 5 root root 4096 Dec 29 01:52 WEB-INF
172
+ drwxr-x--- 3 root root 4096 Dec 29 01:52 org
173
+ ```