Networking problems with WSL2 and Docker Desktop for Windows prevents containerized application to connects to SQL server

We are using Testcontainers for integration testing purposes, to run an ASP.NET Web API application and database running on the MSSQL server, but we cannot connect this API to the SQL container. It constantly fails, with SQL Exception as "The server was not found or was not accessible. " While we are able to connect to the database, using SQL Management studio, or just opening the connection to it using PowerShell, the Api container cannot see it, even if they are in the same docker network, as you can see below. We tried to change the network IP address range on docker Desktop also, as we found that maybe in some cases may overlap with the WSL2 default network 172.31.44… but it also didn’t solve our problem.

“Driver”: “bridge”,
“IPAM”: {
“Driver”: “default”,
“Options”: null,
“Config”: [
{
“Subnet”: “10.10.9.0/24”,
“Gateway”: “10.10.9.1”
}
]
},

“Containers”: {
“5ae00253209e651c873b86050309ceb46c46e8f00a8682f597e1dfcb3ef2c053”: {
“Name”: “dotnet-api”,
“EndpointID”: "…,
“MacAddress”: “02:…”,
“IPv4Address”: “10.10.9.3/24”,
“IPv6Address”: “”
},
“ef0774cf056e13135f2e066880a51ea10b2621aded52e4720c7b41f4e9cd0ab8”: {
“Name”: “sql-server”,
“EndpointID”: “5fbd5a6f0c29799e839eb18b62fc4be6dc9e10a623b5aaafce3f77acad7575bf”,
“MacAddress”: “02:…”,
“IPv4Address”: “10.10.9.2/24”,
“IPv6Address”: “”
}
We tried to set the connection string inside the API application to various options, but none of them worked, we tried with SQL container IP Address, Hostname, with localhost, with the Ip address of the WSL2 found on the host machine received with ipconfig, also with the address we received inside WSL2 using ifconfig, with name of the computer but non of them worked.

.WithEnvironment(“DatabaseSettings__DataSource”, sqlContainer.IpAddress + “,1433”) // database listens on this port
.WithEnvironment(“DatabaseSettings__Database”, “DatabaseName”)
.WithEnvironment(“DatabaseSettings__Username”, “username”)
.WithEnvironment(“DatabaseSettings__Password”, “password”)

Does any have some suggestions? Has anybody had similar issues?
Thanks!