version: '3.7'
services:
mysqldb:
image: mysql:8
restart: always
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: poc
ports:
- 8500:3306
volumes:
- db:/var/lib/mysql
redis-to-mysql:
image: redis-to-mysql:1
hostname: redis-to-mysql
ports:
- "8400:8400"
environment:
spring.datasource.url: jdbc:mysql://mysqldb:8500/poc?createDatabaseIfNotExist=true
spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.MySQL8Dialect
spring.datasource.username: root
spring.datasource.password: root
spring.jpa.hibernate.ddl-auto: none
depends_on:
mysqldb:
condition: service_healthy
volumes:
db:
Description:
Using above docker-compose I am getting a connection refused due to a communication link error.
Earlier I was using custom network
networks:
app:
driver: bridge
Also tried using different dialect provided for mysql8.Trying this on Mac M1 machine. Also tried with arm64 vesion of mysql8 and got similar error.
I think mysql allow root access from localhost by default. You could consider from this perspective and let you mysql could be access from any host. Something like
mysql> update mysql.user set host = '%' where user='root';
FYI: https://nemoz.info/run-mysql-from-docker-and-allow-access-from-outside-container/