Trying to establish connection from app container to mysql container in localhost, getting connection refused exception
We are taking a docker approach to call rest api services to adopt microservice approach. We are establishing connection between app container and mysql container While doing so we have written a docker-compose file created mysql container and application container, exposed ports for both containers. Following is command for running docker-compose file docker-compose up.
docker-compose.yml file
version: '3'
services: docker-mysql: image: mysql:latest container_name: mysql-server environment: - MYSQL_ROOT_PASSWORD=abc123 - MYSQL_DATABASE=fitapp - MYSQL_PASSWORD=root ports: - 3307:3306
spring-webap:
build:
dockerfile: Dockerfile
context: .
image: fitapp:1.0
depends_on:
- docker-mysql
ports:
- 8092:8080
spring-webap_1 | Caused by: java.net.ConnectException: Connection refused
spring-webapcan not contactmysql-serveron localhost. Can you please provide the database connection string you are using in your application? - cmoetzing