Using SQL Server Management Studio to remote connect to docker container

Solution 1:

connect via SSMS using the public IP address, followed by comma separator and then the port (xxx.xx.xx.xxx,port)

You'll also need the sa credentials to make this work.

Solution 2:

In your case, Server Name input will become Server IP, port#

Remote setup image

No need of ssh, you just need to expose SQL Server service to the internet.

When Using SQL Server Management Studio to connect to the docker container on local machine, you can use localhost ip. In that case Server Name input will become 127.0.0.1,port#

To clarity, I attached image of my SSMS Connection Dialog

Solution 3:

Following instruction of this site solved it for me on Windows Containers: https://www.sqlshack.com/sql-server-with-a-docker-container-on-windows-server-2016/ It was possible to connect to SQL Server instantly from SSMS.

Give it a try if this is also working on Linux containers with this command:

docker run --name mssqltrek-con1 -d -p 1433:1433 -e sa_password=My$eCurePwd123# -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer

After running this you can retrieve the correct ip with:

docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mssqltrek-con1