We use Microsoft SQL Server as database and Flyway for managing it. Now I'd like to test Flyway scripts by starting SQL Server in Docker and Flyway in my own Docker container that contains all the configuration and all the Flyway database scripts (migrations).
As far as I know, it's not possible to use environment variables within Flyway configuration files. Ideally, this would be possible:
flyway.url=jdbc:sqlserver://${MSSQL_SERVICE_HOST}:${MSSQL_SERVICE_PORT};databaseName=testing_pp
flyway.user=testing_pp
flyway.password=${MSSQL_SERVICE_PASSWORD}
In fact, I need to know the best strategy for both standalone Docker and OpenShift. I'm pretty new to both...
Is there a way to inject the IP address and the port from one running Docker container to another? One that doesn't involve Docker Compose? And what would be the right way to do it in OpenShift? I know that the pods there get the hosts and ports from all running pods as environment variables (see my hypothetic solution). But these variables aren't resolved, it doesn't solve my problem.
How are you doing such tests?
If I am getting you right, the question is about how to connect two docker containers without docker-compose
. In fact docker-compose
doesnt add a lot in these terms - it just automates several steps.
To connect containers, you have to:
Create new user-defined bridge network (done once): docker network create foo
Connect both containers to this network with --network=foo
startup option
Specify container names instead of autogenerated with --name=xyz
Use these names instead of IP addressed in your connection strings.
docker network create foo
docker run -d --rm --name=my-database --network=foo <SQLServerImageName>
docker run -d --rm --name=my-flyway --network=foo <FlyWayImageName>
Now you can connect from Flyway to SQL with server=my-database