I have SQL Server 2016 Express, docker for Windows and IIS installed on my Windows 10 machine.
SQL Server Express is configured to listen on 1455 port. The Northwind
The problem was I didn't disable Windows Firewall correctly.
I turned off Windows Firewall, but only on Domain networks. Windows sees the DockerNAT adapter as a public network. So Windows firewall was blocking the connection to SQL Server.
I turned off Windows Firewall on public networks and I can connect now.
You can try to start the container using network mode as host. In that case the container can connect to applications running on the host machine using localhost as a DNS name.
version: '3'
services:
connectsqlserver:
image: connectsqlserver
build:
context: ./ConnectSqlServer
dockerfile: Dockerfile
network_mode: "host"