two ways of dockerizing a Spring Boot app with MySQL database. Those are;
By creating a docker network
Using docker-compose
version: "3"
services:
server:
image: backend
ports:
- "8080:8080"
environment:
- spring.datasource.url=jdbc:mysql://mysqldb:3306/employeedb?useSSL=false
networks:
- springmysql-net
depends_on:
- mysqldb
mysqldb:
image: mysql:5.7
networks:
- springmysql-net
environment:
- MYSQL_ROOT_PASSWORD=1234
- MYSQL_DATABASE=employeedb
- MYSQL_USER=sa
- MYSQL_PASSWORD=1234
networks:
springmysql-net: