My dotnet core app running in a docker container on my needs to connect to some external service via their IP one of which is an sql database running separately on a remote server hosted on google cloud. The app runs without issue when not running with docker, however with docker it fails with
An error occurred using the connection to database 'PartnersDb' on server '30.xx.xx.xx,39876'. fail: Microsoft.EntityFrameworkCore.Update An exception occurred in the database while saving changes for context type 'Partners.Api.Infrastructure.Persistence.MoneyTransferDbContext'. System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled conn ections were in use and max pool size was reached.
My Docker compose file looks like this
version: "3.5" networks: my-network: name: my_network services: partners: image: partners.api:latest container_name: partners build: context: ./ restart: always ports: - "8081:80" environment: - ASPNETCORE_ENVIRONMENT=Docker - ConnectionStrings:DefaultConnection=Server=30.xx.xx.xx,39876;Database=PartnersDb;User Id=don;Password=Passwor123$ networks: - my-network volumes: - /Users/mine/Desktop/logs:/logs
bin bashed into the running container and I’m able to run pings to the remote sql database server
I’ve also being able to telnet to the remote sql database server on the database port
However, problem arises when i do docker-compose up then I get the error above. Docker version 19.03.5, build 633a0ea is running on MacOS Mojave 10.14.6
I really do not know what to do at this stage.