Why Liquibase docker container can't connect to Mysql docker container?

Viewed 1459

When I execute my docker-compose it shows that liquibase can't connect to MySQL:

am-liquibase_1 | Unexpected error running Liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to jdbc:mysql://am-mysql:3307/am?autoReconnect=true&useSSL=false with driver com.mysql.cj.jdbc.Driver. Could not create connection to database server. Attempted reconnect 3 times. Giving up.

docker-compose.yml:

version: '3'
services:
  am-mysql:
    image: mysql
    ports:
      - "3307:3306"
    environment:
      - MYSQL_DATABASE=am
      - MYSQL_ROOT_PASSWORD=rse_pass_root
  am-liquibase:
    image: "liquibase/liquibase"
    links:
      - am-mysql
    volumes:
      - ./../../../datalake-schema/mysql-migrations:/liquibase/changelog
    command: --changeLogFile=db.changelog-am-db.xml --url=jdbc:mysql://am-mysql:3307/am?autoReconnect=true&useSSL=false --username=root --password=rse_pass_root update

I use macOS if it is important.

0 Answers
Related