flyway / flyway-docker

Official Flyway Docker images
Apache License 2.0
215 stars 82 forks source link

RSA public key is not available client side (option serverRsaPublicKeyFile not set) #117

Open JohnnysMartins opened 1 year ago

JohnnysMartins commented 1 year ago

I tried to follow the Official documentation example to run a docker-compose version having a MySQL and flyway image running the migration but an error about RSA public key is been showed

docker-compose.yml example:


version: '3'
services:
  flyway:
    image: flyway/flyway
    command: -url=jdbc:mysql://db -schemas=myschema -user=root -password=P@ssw0rd -connectRetries=60 migrate
    volumes:
      - .:/flyway/sql
    depends_on:
      - db
  db:
    image: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=P@ssw0rd
    command: ["--default-authentication-plugin=mysql_native_password"]
    ports:
      - 3306:3306

error: image

fatbasstard commented 9 months ago

Found this on StackOverflow: https://stackoverflow.com/questions/72385060/how-to-connect-to-dockerized-mysql-database-with-flyway

But after that I get the following error:

flyway-1  | WARNING: Connection error: Could not connect to address=(host=db)(port=3306)(type=master) : Socket fail to connect to host:db, port:3306. db
flyway-1  | (Caused by db)
Blogem commented 5 months ago

I have solved this issue by changing the command of the flyway container from:

    command: -url=jdbc:mysql://db -schemas=myschema -user=root -password=P@ssw0rd -connectRetries=60 migrate

to:

    command: -url=jdbc:mysql://db?allowPublicKeyRetrieval=true -schemas=myschema -user=root -password=P@ssw0rd -connectRetries=60 migrate

More info here, esp. regarding the security of this (fine for running local containers): https://github.com/metabase/metabase/issues/12545#issuecomment-629320966