Connect to SQL Server in Docker from Mac
Connect to the Docker host and its published port. The port inside the container can differ from the port TableAI needs.
Before you start
Section titled “Before you start”Have a running SQL Server container, a published database port and a SQL account with access to your database. This guide starts after container creation; Microsoft’s container quickstart covers that setup.
Find the published port
Section titled “Find the published port”Run this on the Docker host:
docker psRead the PORTS column for the SQL Server container. For example:
127.0.0.1:1401->1433/tcpThis mapping exposes container port 1433 as host port 1401. For Docker on your Mac, TableAI uses Host 127.0.0.1 and Port 1401.
For Docker on another computer, use that host’s reachable address and published port. A mapping bound to 127.0.0.1 is accessible only from the Docker host.
Check the SQL Server error log for SQL Server is now ready for client connections. before connecting. See Microsoft’s container troubleshooting guide if the container exits or never becomes ready.
Connect to SQL Server in Docker
Section titled “Connect to SQL Server in Docker”- Open a new connection and select SQL Server.
- Enter the Docker host as Host and the published host port as Port.
- Enter the Database, SQL User and Password for that container’s database.
- Configure the server certificate settings.
- Click Test.
- Click Save & Connect after a successful test.
TLS and remote Docker hosts
Section titled “TLS and remote Docker hosts”Configure a trusted server certificate whose name matches Host. For a private CA, select that CA in the connection form. Publishing a container port does not configure its certificate.
For a remote Docker host reached through SSH, use the host address and published port as seen from the SSH server. Follow the SSH tunnel guide for the tunnel settings.
The SQL Server URL format also works here. Substitute the published host port.
If it does not connect
Section titled “If it does not connect”- Container absent from
docker ps: usedocker ps -ato check stopped containers, then inspect its startup error. - Connection refused: compare Port with the host side of the published mapping.
- Login failed: follow error 18456. With a reused data volume, use the password stored in that database, which can differ from the container’s startup setting.
- Certificate failure: check the container’s certificate and TLS repair.
For remote-host timeouts, use connection failed.
Related
Section titled “Related”Return to the SQL Server overview or run your first query.