Я пытаюсь подключить базу данных MariaDB с помощью docker -compose, но получаю следующую ошибку, когда я запускаю контейнеры с помощью команды 'docker -compose up'
application.properties
spring.datasource.hikari.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.hikari.jdbc-url=jdbc:log4jdbc:mariadb://kipit_db:${DATABASE_PORT}/${DATABASE_NAME}?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true
spring.datasource.hikari.username=${DATABASE_USER}
spring.datasource.hikari.password=${DATABASE_PASSWORD}
Dockerfile
FROM openjdk:8-jdk
VOLUME /tmp
EXPOSE 8080
ARG JAR_FILE=build/libs/kipit-0.0.1-SNAPSHOT.jar
ADD ${JAR_FILE} kipit.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/kipit.jar"]
docker -compose.yml
version: '3'
services:
kipit_db:
image: mariadb:10.4
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=test
- MYSQL_PASSWORD=root
kipit:
image: kipit
depends_on:
- kipit_db
ports:
- 8080:8080
- 3308:3306
environment:
- DATABASE_USER=root
- DATABASE_PASSWORD=root
- DATABASE_NAME=test
- DATABASE_PORT=3306
Настройте приложение для весенней загрузки, которое зависит от MariaDB, вызываемого docker -compose . После ввода docker -compose up я получаю:
Журнал ошибок
Creating network "kipit_default" with the default driver
Creating kipit_kipit_db_1 ... done
Creating kipit_kipit_1 ... done
Attaching to kipit_kipit_db_1, kipit_kipit_1
kipit_db_1 | 2020-05-29 05:50:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
kipit_db_1 | 2020-05-29 05:50:40+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
kipit_db_1 | 2020-05-29 05:50:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.13+maria~bionic started.
kipit_db_1 | 2020-05-29 05:50:40+00:00 [Note] [Entrypoint]: Initializing database files
kipit_1 |
kipit_1 | . ____ _ __ _ _
kipit_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
kipit_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
kipit_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
kipit_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
kipit_1 | =========|_|==============|___/=/_/_/_/
kipit_1 | :: Spring Boot :: (v2.2.6.RELEASE)
kipit_1 |
kipit_1 | 2020-05-29 05:50:42 INFO [ main ] c.p.k.KipitApplication : Starting KipitApplication on 0fe8f9293838 with PID 1 (/kipit.jar started by root in /)
kipit_1 | 2020-05-29 05:50:42 INFO [ main ] c.p.k.KipitApplication : The following profiles are active: oauth
kipit_db_1 |
kipit_db_1 |
kipit_db_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
kipit_db_1 | To do so, start the server, then issue the following commands:
kipit_db_1 |
kipit_db_1 | '/usr/bin/mysqladmin' -u root password 'new-password'
kipit_db_1 | '/usr/bin/mysqladmin' -u root -h password 'new-password'
kipit_db_1 |
kipit_db_1 | Alternatively you can run:
kipit_db_1 | '/usr/bin/mysql_secure_installation'
kipit_db_1 |
kipit_db_1 | which will also give you the option of removing the test
kipit_db_1 | databases and anonymous user created by default. This is
kipit_db_1 | strongly recommended for production servers.
kipit_db_1 |
kipit_db_1 | See the MariaDB Knowledgebase at http://mariadb.com/kb or the
kipit_db_1 | MySQL manual for more instructions.
kipit_db_1 |
kipit_db_1 | Please report any problems at http://mariadb.org/jira
kipit_db_1 |
kipit_db_1 | The latest information about MariaDB is available at http://mariadb.org/.
kipit_db_1 | You can find additional information about the MySQL part at:
kipit_db_1 | http://dev.mysql.com
kipit_db_1 | Consider joining MariaDB's strong and vibrant community:
kipit_db_1 | https://mariadb.org/get-involved/
kipit_db_1 |
kipit_db_1 | 2020-05-29 05:50:43+00:00 [Note] [Entrypoint]: Database files initialized
kipit_db_1 | 2020-05-29 05:50:43+00:00 [Note] [Entrypoint]: Starting temporary server
kipit_db_1 | 2020-05-29 05:50:43+00:00 [Note] [Entrypoint]: Waiting for server startup
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] mysqld (mysqld 10.4.13-MariaDB-1:10.4.13+maria~bionic) starting as process 122 ...
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Using Linux native AIO
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Uses event mutexes
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Number of pools: 1
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Using SSE2 crc32 instructions
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Completed initialization of buffer pool
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Creating shared tablespace for temporary tables
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Waiting for purge to start
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: 10.4.13 started; log sequence number 60972; transaction id 21
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] Plugin 'FEEDBACK' is disabled.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
kipit_db_1 | 2020-05-29 5:50:44 0 [Warning] 'user' entry 'root@3787a6d6386a' ignored in --skip-name-resolve mode.
kipit_db_1 | 2020-05-29 5:50:44 0 [Warning] 'user' entry '@3787a6d6386a' ignored in --skip-name-resolve mode.
kipit_db_1 | 2020-05-29 5:50:44 0 [Warning] 'proxies_priv' entry '@% root@3787a6d6386a' ignored in --skip-name-resolve mode.
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] InnoDB: Buffer pool(s) load completed at 200529 5:50:44
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] Reading of all Master_info entries succeeded
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] Added new Master_info '' to hash table
kipit_db_1 | 2020-05-29 5:50:44 0 [Note] mysqld: ready for connections.
kipit_db_1 | Version: '10.4.13-MariaDB-1:10.4.13+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
kipit_db_1 | 2020-05-29 05:50:45+00:00 [Note] [Entrypoint]: Temporary server started.
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.h.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-8080"]
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.c.StandardService : Starting service [Tomcat]
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.33]
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.a.c.c.C.[.[.[/] : Initializing Spring embedded WebApplicationContext
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] o.s.w.c.ContextLoader : Root WebApplicationContext: initialization completed in 2707 ms
kipit_1 | 2020-05-29 05:50:45 INFO [ main ] c.z.h.HikariDataSource : HikariPool-1 - Starting...
kipit_1 | 2020-05-29 05:50:47 ERROR[ main ] c.z.h.p.HikariPool : HikariPool-1 - Exception during pool initialization.
kipit_1 | java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=kipit_db)(port=3306)(type=master) : Socket fail to connect to host:kipit_db, port:3306. Conne
ction refused (Connection refused)
kipit_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:240)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1192)
kipit_1 | at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:620)
kipit_1 | at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:175)
kipit_1 | at org.mariadb.jdbc.Driver.connect(Driver.java:92)
kipit_1 | at net.sf.log4jdbc.sql.jdbcapi.DriverSpy.connect(DriverSpy.java:401)
kipit_1 | at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
kipit_1 | at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
kipit_1 | at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
kipit_1 | at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
kipit_1 | at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
kipit_1 | at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
kipit_1 | at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
kipit_1 | at com.project.kipit.config.DatabaseConfig.dataSource(DatabaseConfig.java:35)
kipit_1 | at com.project.kipit.config.DatabaseConfig$$EnhancerBySpringCGLIB$$37c12367.CGLIB$dataSource$1(<generated>)
kipit_1 | at com.project.kipit.config.DatabaseConfig$$EnhancerBySpringCGLIB$$37c12367$$FastClassBySpringCGLIB$$3aa2a57.invoke(<generated>)
kipit_1 | at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
kipit_1 | at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
kipit_1 | at com.project.kipit.config.DatabaseConfig$$EnhancerBySpringCGLIB$$37c12367.dataSource(<generated>)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
kipit_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
kipit_1 | at java.lang.reflect.Method.invoke(Method.java:498)
kipit_1 | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1511)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1406)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1290)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1210)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789)
kipit_1 | at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
kipit_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
kipit_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
kipit_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
kipit_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882)
kipit_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
kipit_1 | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
kipit_1 | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
kipit_1 | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
kipit_1 | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
kipit_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
kipit_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
kipit_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
kipit_1 | at com.project.kipit.KipitApplication.main(KipitApplication.java:20)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
kipit_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
kipit_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
kipit_1 | at java.lang.reflect.Method.invoke(Method.java:498)
kipit_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
kipit_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
kipit_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
kipit_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
kipit_1 | Caused by: java.sql.SQLNonTransientConnectionException: Socket fail to connect to host:kipit_db, port:3306. Connection refused (Connection refused)
kipit_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:240)
kipit_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.connException(ExceptionMapper.java:101)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createSocket(AbstractConnectProtocol.java:468)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:358)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1187)
kipit_1 | ... 89 common frames omitted
kipit_1 | Caused by: java.net.ConnectException: Connection refused (Connection refused)
kipit_1 | at java.net.PlainSocketImpl.socketConnect(Native Method)
kipit_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
kipit_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
kipit_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
kipit_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
kipit_1 | at java.net.Socket.connect(Socket.java:607)
kipit_1 | at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createSocket(AbstractConnectProtocol.java:463)
Что мне сейчас не хватает? Спасибо