sql-serverdockerssms

Can not connect to sql server docker image


I used the following command to create the container.

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -p 1438:1438 -d mcr.microsoft.com/mssql/server

Obviously changing the password

Then I open SSMS and in the connection I have server name as

localhost,1438

Authentication is set to

SQL Server Authentication

Login is set to

sa

Password is set to my password

I click connect and get the following error

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.) (Framework Microsoft SqlClient Data Provider)

For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver-10054-database-engine-error

Now I can connect to all sorts of DBs through SSMS without any issue, from azure based ones to local dbs.

Why can I not connect to the docker one? The container is showing as running without error in Docker Desktop.


Solution

  • Okay... My own dumb fault.

    I did not notice that it kept shutting down. Basically I had not made the sa password strong enough.

    Fixed now.