$ docker run --rm -v /var/lib/jenkins/workspace/flyway@2/jenkins_flyway/sql:/flyway/sql -v /var/lib/jenkins/workspace/flyway@2/jenkins_flyway/conf:/flyway/conf flyway/flyway:10.13.0 -user=postgres -password=postgres migrate
WARNING: Storing migrations in 'sql' is not recommended and default scanning of this location may be deprecated in a future release
ERROR: No database found to handle "jdbc:postgresql://localhost:5432/mydb"
Таким образом, Docker может читать файл конфигурации, но не может обрабатывать базу данных Postgres.
Я попытался изменить базу данных на MySQL, но все равно получаю ту же ошибку.
Это произошло потому, что я использовал кавычки для значений свойств в своей конфигурации Flyway.
Теперь у меня другая ошибка:
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
docker run --rm -v /var/lib/jenkins/workspace/flyway/jenkins_flyway/sql:/flyway/sql -v /var/lib/jenkins/workspace/flyway/jenkins_flyway/conf:/flyway/conf flyway/flyway:8.5.1 migrate
ERROR: Unable to obtain connection from database (jdbc:postgresql://localhost:5432/flyway) for user 'postgres': Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : 08001
Error Code : 0
Message : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Caused by: java.net.ConnectException: Connection refused (Connection refused)

Итак, я нашел решение и вот они
"jdbc:postgresql://localhost:5432/mydb"Чтобы исправить это, убедитесь, что вы записали файл конфигурации точно так, как указано выше. Я использовал значения в кавычках.
Чтобы исправить это, я изменил следующие свойства в файле postgresql.conf.
listen_addresses = '*'
И добавил следующую строку в мой файл postgres pg_hba.conf
host all all 192.168.1.0/24 md5
"--network=host" в своей команде докера.
Итак, я нашел решения, и они здесь devopsimplant.blogspot.com/2024/05/…