Docker Community Forums

Share and learn in the Docker community.

Connection error to remote SQL server from local docker container

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[10000]
      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"
    name: my_network

    image: partners.api:latest
    container_name: partners
      context: ./
    restart: always
      - "8081:80"
      - ConnectionStrings:DefaultConnection=Server=30.xx.xx.xx,39876;Database=PartnersDb;User Id=don;Password=Passwor123$
      - my-network
      - /Users/mine/Desktop/logs⁩:/logs

I have

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.