I am getting acquainted with Docker and i need to inject it to my application. I have some problems:
My container always fall down and restarts, may be somebody faced a docker-compose in JavaEE application with MySQL.
My dockerfile:
FROM maven:3.6.3-jdk-11
COPY ./ ./
RUN mvn clean package
CMD ["java", "-war","target/javaee_rest_jdbc_todo_list.war"]
docker-compose file
version: "3.7"
services:
api_service:
build: .
hostname: api_service
restart: always
ports:
- 8090:8080
depends_on:
- mysql_db
mysql_db:
image: "mysql:8.0"
hostname: mysql_db
restart: always
ports:
- 3308:3306
environment:
MYSQL_DATABASE: javaee_task_db
MYSQL_USER: user228
MYSQL_PASSWORD: user228
MYSQL_ROOT_PASSWORD: 13574637480326
Also i have flyway plugin in my pom.xml file:
<plugin>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<user>user228</user>
<password>user228</password>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://mysql_db:3308/javaee_task_db?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&connectionCollation=utf8_general_ci&characterSetResults=UTF-8</url>
</configuration>
</plugin>
And my dataSourse url connection:
final static String URL = "jdbc:mysql://mysql_db:3308/javaee_task_db?useSSL=false";
I also attach link to github - https://github.com/MatveyAndrosyukk/javaee_rest_jdbc_todo_list .
I will be veery grateful for your help!
First issue I notice is that the DataSourse URL should use the DB port within a docker network, ie, 3306
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.