Tuesday, June 7, 2022

SQL Server Management Studio With SQL Server inside a docker container

Recently, I downloaded the docker image for SQL Server and wanted to connect to the server via the excellent SQL Server Management Studio. The docker container was run using the following commands

For downloading the SQL Server image:

docker pull mcr.microsoft.com/mssql/server:2019-latest

For setting up the SQL Server and running it:

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>" -p 6433:1433 --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2019-latest

Note that the SQL Server port 1433 has been mapped to port 6433 on the host. This was done because   I already had a SQL server installed on my laptop running at port 1433 which I didn't want to disturb. All this stuff can be read in detail here.

What now remained was to point the SQL Server Management Studio to this SQL Server instance running inside a container. In the "Connect To Server" dialog, the server name was specified as localhost,6433. Authentication: SQL Server Authentication. Username: sa and Password: <YourStrong@Passw0rd>

Some more references:

1. Deploying and running queries on SQL Server in Docker.

2. Connecting Management Studio to SQL Server running on a non-standard port.

No comments:

Post a Comment