Docker公式チュートリアル(Java Development: Eclipse)

Javaの開発をDockerコンテナを使用して行うチュートリアルにおいて、はまったところ、学んだところをメモ書き程度に紹介します。原因調査の手順を学べて結構楽しかったです。

環境

Docker Desktop for Windows

エラー

Docker composeして、Javaのアプリを走らせようとしたところ以下エラーが発生。

:\Users\username\docker_tutorial\2\labs\developer-tools\java-debugging\app>docker-compose up
[+] Running 0/2
 - webserver Error                                                                                                 4.3s
 - database Error                                                                                                  4.3s
[+] Building 2.5s (19/19) FINISHED
 => [registration-database internal] load build definition from Dockerfile                                         0.0s
 => => transferring dockerfile: 479B                                                                               0.0s
 => [registration-webserver internal] load build definition from Dockerfile                                        0.0s
 => => transferring dockerfile: 930B                                                                               0.0s
 => [registration-database internal] load .dockerignore                                                            0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [registration-webserver internal] load .dockerignore                                                           0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [registration-database internal] load metadata for docker.io/library/mysql:5.7                                 2.2s
 => [registration-webserver internal] load metadata for docker.io/library/tomcat:7-jre8                            2.1s
 => [auth] library/mysql:pull token for registry-1.docker.io                                                       0.0s
 => [auth] library/tomcat:pull token for registry-1.docker.io                                                      0.0s
 => [registration-database 1/2] FROM docker.io/library/mysql:5.7@sha256:f2ad209efe9c67104167fc609cca6973c84229394  0.0s
 => [registration-database internal] load build context                                                            0.0s
 => => transferring context: 543B                                                                                  0.0s
 => [registration-webserver 1/6] FROM docker.io/library/tomcat:7-jre8@sha256:3d6475354578a0b083f2e91700dcb8a1275d  0.0s
 => [registration-webserver internal] load build context                                                           0.1s
 => => transferring context: 972.76kB                                                                              0.0s
 => CACHED [registration-database 2/2] ADD  docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/               0.0s
 => [registration-webserver] exporting to image                                                                    0.1s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:95375655fa3ffb93c623ea0f4171ecee7fe393228c037a74ba8f644711c4f96c                       0.0s
 => => naming to docker.io/library/registration-database                                                           0.0s
 => => writing image sha256:4ab18f566c97240f4f97e34f99748d250cbbb2dbcef50d82a71fb7d4fe60fa61                       0.0s
 => => naming to docker.io/library/registration-webserver                                                          0.0s
 => CACHED [registration-webserver 2/6] ADD tomcat/tomcat-users.xml /usr/local/tomcat/conf/                        0.0s
 => CACHED [registration-webserver 3/6] ADD tomcat/run.sh /usr/local/tomcat/bin/run.sh                             0.0s
 => CACHED [registration-webserver 4/6] RUN chmod +x /usr/local/tomcat/bin/run.sh                                  0.0s
 => CACHED [registration-webserver 5/6] ADD tomcat/mysql-connector-java-5.1.36-bin.jar /usr/local/tomcat/lib/      0.0s
 => CACHED [registration-webserver 6/6] RUN mkdir /usr/local/tomcat/webapps/UserSignup                             0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
[+] Running 2/2
 - Container java-debugging-database-1   Created                                                                   0.2s
 - Container java-debugging-webserver-1  Created                                                                   0.1s
Attaching to java-debugging-database-1, java-debugging-webserver-1
java-debugging-database-1   | 2022-01-18 01:36:53+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
java-debugging-database-1   | 2022-01-18 01:36:53+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
java-debugging-database-1   | 2022-01-18 01:36:53+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
java-debugging-database-1   | 2022-01-18 01:36:53+00:00 [Note] [Entrypoint]: Initializing database files
java-debugging-database-1   | 2022-01-18T01:36:53.991232Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
java-debugging-database-1   | 2022-01-18T01:36:54.150485Z 0 [Warning] InnoDB: New log files created, LSN=45790
java-debugging-database-1   | 2022-01-18T01:36:54.204773Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
java-debugging-database-1   | 2022-01-18T01:36:54.288797Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 1ddacfd0-77ff-11ec-b959-0242ac120002.
java-debugging-database-1   | 2022-01-18T01:36:54.292556Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
java-debugging-database-1   | 2022-01-18T01:36:55.130475Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
java-debugging-database-1   | 2022-01-18T01:36:55.130506Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
java-debugging-database-1   | 2022-01-18T01:36:55.130945Z 0 [Warning] CA certificate ca.pem is self signed.
java-debugging-database-1   | 2022-01-18T01:36:55.384125Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
java-debugging-webserver-1  | standard_init_linux.go:228: exec user process caused: no such file or directory
java-debugging-webserver-1 exited with code 0
java-debugging-database-1   | 2022-01-18 01:36:59+00:00 [Note] [Entrypoint]: Database files initialized
java-debugging-database-1   | 2022-01-18 01:36:59+00:00 [Note] [Entrypoint]: Starting temporary server
java-debugging-database-1   | 2022-01-18 01:36:59+00:00 [Note] [Entrypoint]: Waiting for server startup
java-debugging-database-1   | 2022-01-18T01:36:59.279683Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
java-debugging-database-1   | 2022-01-18T01:36:59.280933Z 0 [Note] mysqld (mysqld 5.7.36) starting as process 78 ...
java-debugging-database-1   | 2022-01-18T01:36:59.283967Z 0 [Note] InnoDB: PUNCH HOLE support available
java-debugging-database-1   | 2022-01-18T01:36:59.284010Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
java-debugging-database-1   | 2022-01-18T01:36:59.284015Z 0 [Note] InnoDB: Uses event mutexes
java-debugging-database-1   | 2022-01-18T01:36:59.284017Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
java-debugging-database-1   | 2022-01-18T01:36:59.284019Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
java-debugging-database-1   | 2022-01-18T01:36:59.284021Z 0 [Note] InnoDB: Using Linux native AIO
java-debugging-database-1   | 2022-01-18T01:36:59.284279Z 0 [Note] InnoDB: Number of pools: 1
java-debugging-database-1   | 2022-01-18T01:36:59.284426Z 0 [Note] InnoDB: Using CPU crc32 instructions
java-debugging-database-1   | 2022-01-18T01:36:59.286767Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
java-debugging-database-1   | 2022-01-18T01:36:59.298122Z 0 [Note] InnoDB: Completed initialization of buffer pool
java-debugging-database-1   | 2022-01-18T01:36:59.300835Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
java-debugging-database-1   | 2022-01-18T01:36:59.313317Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
java-debugging-database-1   | 2022-01-18T01:36:59.324885Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
java-debugging-database-1   | 2022-01-18T01:36:59.324974Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
java-debugging-database-1   | 2022-01-18T01:36:59.342439Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
java-debugging-database-1   | 2022-01-18T01:36:59.342853Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
java-debugging-database-1   | 2022-01-18T01:36:59.342880Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
java-debugging-database-1   | 2022-01-18T01:36:59.344345Z 0 [Note] InnoDB: 5.7.36 started; log sequence number 2749723
java-debugging-database-1   | 2022-01-18T01:36:59.344487Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
java-debugging-database-1   | 2022-01-18T01:36:59.344757Z 0 [Note] Plugin 'FEDERATED' is disabled.
java-debugging-database-1   | 2022-01-18T01:36:59.346595Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220118  1:36:59
java-debugging-database-1   | 2022-01-18T01:36:59.351610Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
java-debugging-database-1   | 2022-01-18T01:36:59.351667Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
java-debugging-database-1   | 2022-01-18T01:36:59.351672Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
java-debugging-database-1   | 2022-01-18T01:36:59.351674Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
java-debugging-database-1   | 2022-01-18T01:36:59.352252Z 0 [Warning] CA certificate ca.pem is self signed.
java-debugging-database-1   | 2022-01-18T01:36:59.352299Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
java-debugging-database-1   | 2022-01-18T01:36:59.356395Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
java-debugging-database-1   | 2022-01-18T01:36:59.362552Z 0 [Note] Event Scheduler: Loaded 0 events
java-debugging-database-1   | 2022-01-18T01:36:59.362876Z 0 [Note] mysqld: ready for connections.
java-debugging-database-1   | Version: '5.7.36'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
java-debugging-database-1   | 2022-01-18 01:37:00+00:00 [Note] [Entrypoint]: Temporary server started.
java-debugging-webserver-1 exited with code 1
java-debugging-database-1   | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
java-debugging-database-1   | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.java-debugging-database-1   | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
java-debugging-database-1   | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
java-debugging-database-1   | 2022-01-18 01:37:02+00:00 [Note] [Entrypoint]: Creating database dockercon2035
java-debugging-database-1   | 2022-01-18 01:37:02+00:00 [Note] [Entrypoint]: Creating user gordon
java-debugging-database-1   | 2022-01-18 01:37:02+00:00 [Note] [Entrypoint]: Giving user gordon access to schema dockercon2035
java-debugging-database-1   |
java-debugging-database-1   | 2022-01-18 01:37:02+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initialize_db.sql
java-debugging-database-1   |
java-debugging-database-1   |
java-debugging-database-1   | 2022-01-18 01:37:02+00:00 [Note] [Entrypoint]: Stopping temporary server
java-debugging-database-1   | 2022-01-18T01:37:02.359909Z 0 [Note] Giving 0 client threads a chance to die gracefully
java-debugging-database-1   | 2022-01-18T01:37:02.359959Z 0 [Note] Shutting down slave threads
java-debugging-database-1   | 2022-01-18T01:37:02.359964Z 0 [Note] Forcefully disconnecting 0 remaining clients
java-debugging-database-1   | 2022-01-18T01:37:02.359968Z 0 [Note] Event Scheduler: Purging the queue. 0 events
java-debugging-database-1   | 2022-01-18T01:37:02.360046Z 0 [Note] Binlog end
java-debugging-database-1   | 2022-01-18T01:37:02.360430Z 0 [Note] Shutting down plugin 'ngram'
java-debugging-database-1   | 2022-01-18T01:37:02.360460Z 0 [Note] Shutting down plugin 'partition'
java-debugging-database-1   | 2022-01-18T01:37:02.360464Z 0 [Note] Shutting down plugin 'BLACKHOLE'
java-debugging-database-1   | 2022-01-18T01:37:02.360466Z 0 [Note] Shutting down plugin 'ARCHIVE'
java-debugging-database-1   | 2022-01-18T01:37:02.360468Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
java-debugging-database-1   | 2022-01-18T01:37:02.360486Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
java-debugging-database-1   | 2022-01-18T01:37:02.360488Z 0 [Note] Shutting down plugin 'MyISAM'
java-debugging-database-1   | 2022-01-18T01:37:02.360493Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
java-debugging-database-1   | 2022-01-18T01:37:02.360496Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
java-debugging-database-1   | 2022-01-18T01:37:02.360497Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
java-debugging-database-1   | 2022-01-18T01:37:02.360498Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
java-debugging-database-1   | 2022-01-18T01:37:02.360500Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
java-debugging-database-1   | 2022-01-18T01:37:02.360501Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
java-debugging-database-1   | 2022-01-18T01:37:02.360503Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
java-debugging-database-1   | 2022-01-18T01:37:02.360515Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
java-debugging-database-1   | 2022-01-18T01:37:02.360521Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
java-debugging-database-1   | 2022-01-18T01:37:02.360525Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
java-debugging-database-1   | 2022-01-18T01:37:02.360530Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
java-debugging-database-1   | 2022-01-18T01:37:02.360536Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
java-debugging-database-1   | 2022-01-18T01:37:02.360539Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
java-debugging-database-1   | 2022-01-18T01:37:02.360542Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
java-debugging-database-1   | 2022-01-18T01:37:02.360545Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
java-debugging-database-1   | 2022-01-18T01:37:02.360589Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
java-debugging-database-1   | 2022-01-18T01:37:02.360593Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
java-debugging-database-1   | 2022-01-18T01:37:02.360614Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
java-debugging-database-1   | 2022-01-18T01:37:02.360616Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
java-debugging-database-1   | 2022-01-18T01:37:02.360617Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
java-debugging-database-1   | 2022-01-18T01:37:02.360619Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
java-debugging-database-1   | 2022-01-18T01:37:02.360620Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
java-debugging-database-1   | 2022-01-18T01:37:02.360621Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
java-debugging-database-1   | 2022-01-18T01:37:02.360623Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
java-debugging-database-1   | 2022-01-18T01:37:02.360624Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
java-debugging-database-1   | 2022-01-18T01:37:02.360626Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
java-debugging-database-1   | 2022-01-18T01:37:02.360629Z 0 [Note] Shutting down plugin 'INNODB_CMP'
java-debugging-database-1   | 2022-01-18T01:37:02.360631Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
java-debugging-database-1   | 2022-01-18T01:37:02.360634Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
java-debugging-database-1   | 2022-01-18T01:37:02.360636Z 0 [Note] Shutting down plugin 'INNODB_TRX'
java-debugging-database-1   | 2022-01-18T01:37:02.360638Z 0 [Note] Shutting down plugin 'InnoDB'
java-debugging-database-1   | 2022-01-18T01:37:02.360706Z 0 [Note] InnoDB: FTS optimize thread exiting.
java-debugging-database-1   | 2022-01-18T01:37:02.360839Z 0 [Note] InnoDB: Starting shutdown...
java-debugging-database-1   | 2022-01-18T01:37:02.461466Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
java-debugging-database-1   | 2022-01-18T01:37:02.461751Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 220118  1:37:02
java-debugging-webserver-1 exited with code 1
java-debugging-webserver-1 exited with code 1
java-debugging-database-1   | 2022-01-18T01:37:04.183147Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12664620
java-debugging-database-1   | 2022-01-18T01:37:04.184448Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
java-debugging-database-1   | 2022-01-18T01:37:04.184488Z 0 [Note] Shutting down plugin 'MEMORY'
java-debugging-database-1   | 2022-01-18T01:37:04.184494Z 0 [Note] Shutting down plugin 'CSV'
java-debugging-database-1   | 2022-01-18T01:37:04.184497Z 0 [Note] Shutting down plugin 'sha256_password'
java-debugging-database-1   | 2022-01-18T01:37:04.184499Z 0 [Note] Shutting down plugin 'mysql_native_password'
java-debugging-database-1   | 2022-01-18T01:37:04.184589Z 0 [Note] Shutting down plugin 'binlog'
java-debugging-database-1   | 2022-01-18T01:37:04.185114Z 0 [Note] mysqld: Shutdown complete
java-debugging-database-1   |
java-debugging-database-1   | 2022-01-18 01:37:04+00:00 [Note] [Entrypoint]: Temporary server stopped
java-debugging-database-1   |
java-debugging-database-1   | 2022-01-18 01:37:04+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
java-debugging-database-1   |
java-debugging-database-1   | 2022-01-18T01:37:04.529106Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
java-debugging-database-1   | 2022-01-18T01:37:04.530572Z 0 [Note] mysqld (mysqld 5.7.36) starting as process 1 ...
java-debugging-database-1   | 2022-01-18T01:37:04.533541Z 0 [Note] InnoDB: PUNCH HOLE support available
java-debugging-database-1   | 2022-01-18T01:37:04.533586Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
java-debugging-database-1   | 2022-01-18T01:37:04.533594Z 0 [Note] InnoDB: Uses event mutexes
java-debugging-database-1   | 2022-01-18T01:37:04.533602Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
java-debugging-database-1   | 2022-01-18T01:37:04.533607Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
java-debugging-database-1   | 2022-01-18T01:37:04.533611Z 0 [Note] InnoDB: Using Linux native AIO
java-debugging-database-1   | 2022-01-18T01:37:04.533931Z 0 [Note] InnoDB: Number of pools: 1
java-debugging-database-1   | 2022-01-18T01:37:04.534072Z 0 [Note] InnoDB: Using CPU crc32 instructions
java-debugging-database-1   | 2022-01-18T01:37:04.535617Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
java-debugging-database-1   | 2022-01-18T01:37:04.544896Z 0 [Note] InnoDB: Completed initialization of buffer pool
java-debugging-database-1   | 2022-01-18T01:37:04.547258Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
java-debugging-database-1   | 2022-01-18T01:37:04.558792Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
java-debugging-database-1   | 2022-01-18T01:37:04.568924Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
java-debugging-database-1   | 2022-01-18T01:37:04.569000Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
java-debugging-database-1   | 2022-01-18T01:37:04.582112Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
java-debugging-database-1   | 2022-01-18T01:37:04.582665Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
java-debugging-database-1   | 2022-01-18T01:37:04.582693Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
java-debugging-database-1   | 2022-01-18T01:37:04.583492Z 0 [Note] InnoDB: Waiting for purge to start
java-debugging-database-1   | 2022-01-18T01:37:04.633775Z 0 [Note] InnoDB: 5.7.36 started; log sequence number 12664620
java-debugging-database-1   | 2022-01-18T01:37:04.634084Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
java-debugging-database-1   | 2022-01-18T01:37:04.634359Z 0 [Note] Plugin 'FEDERATED' is disabled.
java-debugging-database-1   | 2022-01-18T01:37:04.636398Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220118  1:37:04
java-debugging-database-1   | 2022-01-18T01:37:04.638741Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
java-debugging-database-1   | 2022-01-18T01:37:04.638775Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
java-debugging-database-1   | 2022-01-18T01:37:04.638779Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
java-debugging-database-1   | 2022-01-18T01:37:04.638781Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
java-debugging-database-1   | 2022-01-18T01:37:04.639285Z 0 [Warning] CA certificate ca.pem is self signed.
java-debugging-database-1   | 2022-01-18T01:37:04.639325Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
java-debugging-database-1   | 2022-01-18T01:37:04.639872Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
java-debugging-database-1   | 2022-01-18T01:37:04.639923Z 0 [Note] IPv6 is available.
java-debugging-database-1   | 2022-01-18T01:37:04.639934Z 0 [Note]   - '::' resolves to '::';
java-debugging-database-1   | 2022-01-18T01:37:04.639943Z 0 [Note] Server socket created on IP: '::'.
java-debugging-database-1   | 2022-01-18T01:37:04.643768Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
java-debugging-database-1   | 2022-01-18T01:37:04.650859Z 0 [Note] Event Scheduler: Loaded 0 events
java-debugging-database-1   | 2022-01-18T01:37:04.651209Z 0 [Note] mysqld: ready for connections.
java-debugging-database-1   | Version: '5.7.36'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
java-debugging-webserver-1 exited with code 1
java-debugging-webserver-1 exited with code 1
java-debugging-webserver-1 exited with code 1
java-debugging-webserver-1 exited with code 1

重要そうなメッセージはこれっぽい。
java-debugging-webserver-1においてファイルかディレクトリがないっぽい。

java-debugging-webserver-1  | standard_init_linux.go:228: exec user process caused: no such file or directory

原因調査

jave-debugging-webserver-1のDocker fileを見てみます。

Base imageの後は、ADDを2回。それぞれのファイルはホスト側に存在しているので問題なさそう。その後、シェルスクリプトファイルに実行権限を与えて、RUNしている。

RUN chmod +x $CATALINA_HOME/bin/run.sh

実際にコンテナの中に入って、run.shを実行してみることにする。

Docker exec -it --rm jave-debugging-webserver bash

以下のように実行すると、/bin/shの後に「^M」と表示されて、No such file or directoryのエラーメッセージが表示される。^Mは改行コード(CR)で、「Windowsの改行コードCRLF」のファイルを「Linuxの改行コードLF」で開いたときに起きる。

OSによって改行コードは異なる。

  • CRLF : Windowsの改行コード
  • LF : Linuxの改行コード

今回は、Windows上のファイルをBuild時にLinux環境のコンテナ内にコピーされて、Windowsの改行コードを持ったシェルスクリプトファイル(run.sh)が存在してしまった。その結果、そのシェルスクリプトファイルを実行した際にエラーが発生したと推測できる。

では、なぜWindows上のファイルは改行コードを含んでいたのか?別にこのファイルはWindows上で作成した訳ではないのに。ファイルはGit cloneされたもので、このclone時に改行コードが変わってしまっていたらしい。Git for Windowsには改行コードを自動変換する機能があるらしい。

LF(Linuxの改行コード)ー> CRLF(Windowsの改行コード)

この事例は昔からあるようだ。私は今日知ったが。

core.autocrlf で自動変換の設定が可能とのこと。実は結構複雑なのだが、結論以下をセットすればとりあえずはOK。

git config --global core.autocrlf false

その後、Git cloneし直すと、改行コードが変換されずに、無事にDocker-composeによりアプリケーションを立ち上げることができた。

学んだこと

  • WindowsとLinuxの改行コードについて、Git cloneの改行コード自動変換について
  • エラーは丁寧に読むこと、そして上から順に調べること。
  • エラーに関連しそうな箇所を実際に一つ一つ再現してみる。今回ではコンテナ内でのシェルスクリプトの実行。

非常に基本的なことなんだろうけど、自分にとってはいい勉強になった。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です