Using SQL Server Management Studio to remote connect to docker container

前端 未结 6 2010
北荒
北荒 2021-02-05 00:22

Context: I am trying to build a development SQL Server that I can continue to learn SQL on and use Microsoft SQL Server Management Studio (SSMS) to

相关标签:
6条回答
  • 2021-02-05 00:57

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

    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#

    0 讨论(0)
  • 2021-02-05 01:04

    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.

    0 讨论(0)
  • 2021-02-05 01:08

    I also faced same issue when I try to connect through SSMS, even I tried with localhost,1433 it doesn't help me out. enter image description here

    After some R&D I found the way to solve it

    • Open Kubernetes which will be installed as part of docker toolbox (mine was win 10 home which will not support hyper-v)
    • click on sql container which will be in left side of app
    • copy the IP address which will be in right side of app
    • use IP address with port like XXX.XXX.XX.XX,1433 along with credentials in SSMS

    enter image description here

    0 讨论(0)
  • 2021-02-05 01:20

    You can connect to SQL docker server

    1. Using IP of Machine on which docker image is hosted,port

    IP_Of_Machine,Port

    1. Provide User - sa (default) and password.

    2. you can also do it command>

    docker exec -it <container_id|container_name> /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your_password>

    0 讨论(0)
  • 2021-02-05 01:22

    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
    
    0 讨论(0)
  • 2021-02-05 01:22

    In my case it was the Cisco VPN that was blocking the host to connect to container IP. I had to uncheck the "Cisco Any Connect Network Access Manager" as shown in the image below for it to work. It ensures that the VPN no longer manages the connection.

    0 讨论(0)
提交回复
热议问题