On the same virutal machine (remote, ubuntu), I have

* **An SQL Server** running in a Docker
* **An .NET Core 2.2** (IdentityServer) application running in a docker
* **An instance of [jwilder.nginx-proxy](https://github.com/jwilder/nginx-proxy)** serving as a reverse-proxy for every web application on the machine
* A multitude of other .NET Core apps

I am able to connect to all of my websites using both machine IP + port and domain name, which means the reverse proxy works as expected and the dockers are well-configured

**I am able to connect** to the SQL Server **using SSMS** from my local machine, which means that the SQL Server docker properly forwards the TCP connection on port 1433

The IdentityServer .NET Core 2 web application **is able to connect** to the SQL Server **when run on my local machine**.

**The remote-docker IdentityServer application can't reach the SQL Server instance** with the following error (shortened for clarity - removed stack trace)

> 
> `System.Data.SqlClient.SqlException (0x80131904)`:
> 
> 
> A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
> 
> 
> (provider: `TCP Provider, error: 40` - Could not open a connection to SQL Server) at [...]
> 
> 
> 

I know that the SQL server is running and reachable from the internet, and I know that the application's code is not at fault because I tested both.

So I deduced it had to be the IdentityServer docker that was blocking the connexion. So I tried:

* Using the `--expose 20` command on the IdentityServer docker
* Opening mapping the port 20 inside the container to some port outside `-p 45264:20` in addition to the already exposed port 80
* I originally worked on using the port 1433 on both sides of the mapping but since it didn't work I tried using an other port on the outside (20). Didn't change anything

Here is the connexion string used by the IdentityServer (sensitive data hidden):

```
Data Source=***.***.***.***,20;Initial Catalog=Identity;Persist Security Info=True;User ID=**;Password=******************

```

Why can't my IdentityServer docker reach the SQL Server docker while the SQL Server itself is perfectly reachable? How can I make this setup work?