none
Can't connect SSMS to container instance of sql server express RRS feed

  • Question

  • As the title states, I am having trouble connecting SSMS to my local microsoft/mssql-server-2016-express-windows container. Using docker version 1.12.3-beta30.1 (8711) and switching to windows containers I run the following docker command.

    docker run -d -p 1433:1433 --env sa_password=34B1dKdXzoUB -it microsoft/mssql-server-2016-express-windows

    (password was randomly generated by a tool)

    If I look at the log output in kitematic i see that the container was started properly:

    JHVERBOSE: Starting SQL Server
    VERBOSE: Changing SA login credentials
    VERBOSE: Started SQL Server.

    But when i attempt to log on to the server using SSMS  with the server as localhost\sqlexpress which i believe to be the default instance based on the github docs 

    

    Is there something I am missing when running the docker run command or when trying to connect with SSMS?

    Any help you can provide is appreciated.

    Thanks.

    Wednesday, November 30, 2016 1:16 AM

All replies

  • Try adding the port right after the hostname, like so:

    localhost,1433\sqlexpress

    Regards,
    Dimitar

    Wednesday, November 30, 2016 8:37 AM
  • Thanks for the replay Dimitar, unfortunately that did not work.


    Wednesday, November 30, 2016 10:55 AM
  • Here are some other things you may try:

    • Connect from a different machine i.e. not the docker host.
    • Try to use the IP address (again with the port) instead of localhost.
    • Try to connect without the Instance name.
    • Make sure port 1433 is not occupied by another process. Do you have another SQL Server running on the host?
    • Turn off the firewall.

    Regards!


    Wednesday, November 30, 2016 11:26 AM
  • I would try to (if you running on Win10 host):

    • access using an IP address of the container,
    • don`t publish your port (-p [host_port]:[container_port]) because of possible conflict of your local/host ports,
    • instead, expose the container port (--expose [container_port]).

    Later, as Dimitar says, connect the instance like this:

    [container_ip],[container_port]

    or

    [container_ip],[container_port]\sqlexpress.



    • Edited by Jakub Vanak Wednesday, November 30, 2016 3:53 PM
    Wednesday, November 30, 2016 3:51 PM
  • If on the Docker run command you use 

    -p 1434:1433

    then there will not be a conflict with SQL Server on the host and you can connect SSMS up to it from the Host using the Container's ip address like this

    172.29.152.33,1433\sqlexpress

    Note that the port number used is the internal port number.

    And you can connect from other PCs like this:

    MYMACHINE,1434\sqlexpress

    But connecting from the host using localhost does not work:

    localhost,1434\sqlexpress

    regards Rob Goodridge

    • Proposed as answer by Rob Goodridge Tuesday, May 30, 2017 7:21 AM
    Tuesday, May 30, 2017 7:21 AM