spring - Docker container accessing external MySQL host -
i have setup spring-boot docker container in ec2 instance(ec2_ip) , have mysql hosted in different vm. verified that mysql host(mysql_ip) accessible ec2 instance hosting docker container.
i passing spring.datasource.url parameters using docker environment variables during docker run.
the spring boot app fails complaining error message access denied user db_user@ec2_ip. part unable understand , fix. don't understand why trying connect ec2_ip instead of db_user@mysql_ip.
i did docker inspect , verified environment variable spring.datasoure.url passed correctly , db_user@mysql_ip:3306.
i have spent hours trying fix problem, no luck. appreciated.
to clarify based on comments, have datasource configured correctly.
inside docker inspect, value of args:
-dspring.datasource.url=jdbc:mysql://mysql_ip:3306/test
also, checked if pass invalid ip (eg) random text, throws error saying host invalid (this confirms, taking host pass in). however, if configure external ip, seems resolve host ip address (ec2_ip).
you need set both
spring.datasource.url=jdbc:mysql://localhost/test spring.datasource.username=dbuser spring.datasource.password=dbpass
as specified here
Comments
Post a Comment