Connect to SQL Server in a Docker container from Parallels guest using SSMS

705 views Asked by At

I am working with a MacBook M1 that runs a SQL Server database using microsoft-azure-sql-edge image. On the same laptop is running a Win 11 VM using Parallels where SQL Server Management Studio is installed.

The issue is that I can't connect to the database from the Windows VM. I tried to give a hostname to the database container and connect it to the host network using this docker compose config:

version: "3.9"

services:
  mssql:
    image: mcr.microsoft.com/azure-sql-edge:latest
    command: /opt/mssql/bin/sqlservr
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: ${SAPassword}
    stdin_open: true
    container_name: sqlserver
    hostname: sqlserver
    network_mode: host
    ports:
      - 1433:1433

I tried to set sqlserver as server name and enter the login for sa but I get an error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server

2

There are 2 answers

1
Sean Chase On

Assuming a typical Parallels installation and your configuration is following something like this: https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker

  1. On your Mac OS, open a Terminal.
  2. Run ifconfig to find your Bridge IP which will be something like 10.211.55.2 (not your 192.168.x.x).
  3. Ensure that your SQL Server container is running in docker.
  4. In SSMS, connect using that IP address as the server name, use your docker configured SA login setting authentication type to SQL Server Authentication.

That's it!

0
Anurag Gandhi On

I was also facing the similar issue. Now I am able to connect.

in Server: , for example, if your ip address is: 192.168.0.189 and port is 1433, you need to enter: 192.168.0.189,1433

Choose Sql server authentication and enter correct username and password.

it worked for me.