I am trying to put an application on docker spring-boot + mysql. The problem is that I am working on a MacBook M1 and all my attempts fail.
I get the database image from dockerhub, the application image also builds for me without any hindrance but the application won't start because there is a database connection error.
My Dockerfile
FROM arm64v8/openjdk:11.0.15-jdk-bullseye
ADD target/patient-registration-0.0.1-SNAPSHOT.jar .
EXPOSE 8080
CMD java -jar patient-registration-0.0.1-SNAPSHOT.jar
My docker-compose.yml
version: '3.8'
services:
database:
container_name: patient_db
image: 'mysql:8.0.22'
platform: linux/x86_64
environment:
- MYSQL_ROOT_PASSWORD=mysql
- MYSQL_USER=mysql
- MYSQL=patient_db
- MYSQL_PORT=3306
restart: always
patient_reservation:
image: 'patient_reservation'
build: .
ports:
- "8282:8282"
environment:
- SPRING_DATASOURCE_URL=jdbc:mysql://database:3306/patient_db?useUnicode=true&characterEncoding=utf8&useSSLdo=false&useLegacyDatetimeCode=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
- SPRING_DATASOURCE_USERNAME=mysql
- SPRING_DATASOURCE_PASSWORD=mysql
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
restart: always
depends_on:
- database
I would greatly appreciate it!
Thank you in advance !