Docker Community Forums

Share and learn in the Docker community.

Docker (on Windows) - com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

Hi,
I am running the below compose file. However, I am getting the communication link failure error.

Docker-Compose:

version: ‘3.8’
services:
roomservices_db:
image: mysql:5.7
environment:
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: Test
ports:
- 3307:3306
volumes:
- ./:/var/lib/mysql/:rw

roomservices:
#image: roomservices:latest
depends_on:
- roomservices_db
ports:
- 8080:8080
build:
context: .
dockerfile: Dockerfile
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://roomservices_db:3306/roomservicesdb?createDatabaseIfNotExist=true
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: Test


Dockerfile

OpenJDK 8

FROM openjdk:8u262

Copy the Application Jar onto the Docker Image

COPY Application-0.0.1-SNAPSHOT.jar Application-0.0.1-SNAPSHOT.jar

Exposes the application port, to the outside world.

EXPOSE 8080

set the startup command to execute the jar

CMD [“java”, “-jar”, “Application-0.0.1-SNAPSHOT.jar”]

I am not sure if there is an issue with my database properties, I tried different settings and port but had no luck.

Any help would be greatly appreciated.

Thanks