Can't connect to SQL Server 2019 (or any other version) from SQL Management Studio

I’m trying to start SQL Server Developer as a Docker container and then connect to it using my app. But to test this, after starting the container I try to connect via SQL Server Management Studio using the Server Name: localhost, port, where port is the port of the container. I had this working for one day, but it no longer works. Now I get: "A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (Provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) Microsoft SQL Server Error: 10054). An existing connection was forcibly closed by the remote host.

I’ve tried this with all recent version of SQL Server and on two machines - one running Windows 10 and the other running Windows Server 2022.

I’ve looked up that error code and it seems to be related to TLS, The (host) machine has all versions of TLS set up correctly. I have no idea what’s going on with respect to TLS inside the container, (I’m a Windows guy and haven’t worked much at all with Linux),

Any help would be appreciated. I’ve burned several days on this and gotten nowhere.

Missing a lot of details, you run Docker Desktop on Windows? How do you start SQL Server Developer? Is the SQL Server Developer image for Windows or Linux?

Sorry for the lack of details. Very new to Docker. Yes - Docker desktop for Windows. I start SQL Server using this:

docker run -e "ACCEPT_EULA=YES" -e "SA_PASSWORD=P@ssword123" -p 1443:1443 -d mcr.microsoft.com/mssql/server:2017-latest

I have no idea if the image is for Windows or Linux. I thought everything running inside a container was running on Linux, so I assume Linux. I’ve tried …server:2019-latest as well - same issue.

Hello

The latest time I’ve tried (for just the fun), here is how I’ve done.

On my console, run docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=2Secure*Password2" -p 1433:1433 --name sqlserverdb -h mysqlserver -d mcr.microsoft.com/mssql/server:2022-latest.

I’ve then a running container opened on port 1433 and the password for the SA user is 2Secure*Password2>.

Then I download SSMS from Download SQL Server Management Studio (SSMS) - SQL Server Management Studio (SSMS) | Microsoft Learn and start it.

In my SSMS login screen, I set these values:

  • Server name: localhost,1433
  • Authentication: SQL Server Authentication
  • Login: SA
  • Password: 2Secure*Password2

And then I’ve well connected and can create databases, tables, …

Thanks @cavo789 - that works! It’s not much different than what I was doing other than adding the hostname and name. Not sure why that makes it work, but just glad it’s working! Thanks again!