Run SQL Server Linux container images with Docker

In this post, you use Docker to pull and run the SQL Server Linux container image and see the demo of connecting from SQL Server Management Studio (SSMS).

Open your PowerShell with elevated permission and run the following command. It pulls the SQL Server 2022 (16.x) Linux container image from the Microsoft Container Registry.

docker run -e «ACCEPT_EULA=Y» -e «MSSQL_SA_PASSWORD=<password>» -p 1433:1433 —name sql1 —hostname sql1 -d mcr.microsoft.com/mssql/server:2022-latest

Fig 1: Docker run — SQL Server Linux Container

Parameter
Description

-e “ACCEPT_EULA=Y”
confirm your acceptance of the End-User Licensing Agreement.

-e “MSSQL_SA_PASSWORD=»
Specify your own strong password.

-p 1433:1433
Map a TCP port on the host environment (first value) with a TCP port in the container (second value).

–name sql1
Name of the container

–hostname sql1
Container hostname

-d
Run the container in the background daemon

mcr.microsoft.com/mssql/server:2022-latest
The SQL Server Linux container image.

Run the following command, “docker ps” to view your Docker containers.

Fig 2: Docker ps — View containers

If the STATUS column shows Up, then SQL Server is running in the Docker container and listening on the port.

Docker engine,

Fig 3: Docker Engine

Connect the SQL Server from SSMS,

Fig 4: SSMS — Connect SQL Server

List all the database,

Fig 5: Database list view

Test database,

Fig 6: Test database

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *