Deploy a SQL Server 2022 container in less than 10 minutes

Richard P
2 min readSep 14, 2023

Set up a SQL Server database in less than 10 minutes using Docker. With a containerized version of SQL Server, you can run the database server anywhere you can install docker. For instance, this setup was a breeze on my old Macbook Air 8. Interestingly, the OS for the SQL Server container image is Ubuntu 20.04.6.

Photo by Jan Antonin Kolar on Unsplash

Docker compose.yaml file to create a SQL Server 2022 Container with persistent volumes

  • Linux OS
  • Persistent data storage with volumes
  • Changes the SA password

To start the container, run docker-compose up -d from the working directory with the compose.yaml file.

After starting the container, SQL Server will startup. This takes about a minute for my blank database. You can then connect to the SQL Server on port 1433 using the ‘sa’ account and the password set in the compose.yaml file.

Inspect the container

Since we are running SQL Server in a container, we should investigate to see how many cores it is using, confirm SQL version, and other diagnostic info:

-- SQL Server version
SELECT @@version;

Microsoft SQL Server 2022 (RTM-CU7) (KB5028743) — 16.0.4065.3 (X64)
Jul 25 2023 18:03:43
Copyright © 2022 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 20.04.6 LTS) <X64>

-- Hardware and core info
select
cpu_count,
physical_memory_kb,
sqlserver_start_time,
virtual_machine_type_desc,
socket_count,
cores_per_socket,
container_type_desc
from sys.dm_os_sys_info;
-- Compatibility level
SELECT
name,
compatibility_level,
state_desc…

--

--