/ notes / sql
⇒ This is just a collection of notes, not a structured or comprehensive document. ⇐

SQL 2025 with Podman

A brief step-by-step for running SQL Server 2025 on Podman on Windows 11 (WSL) and deploying a database on it.

Podman setup

  1. Pull the SQL Server 2025 image
podman pull mcr.microsoft.com/mssql/server:2025-latest
  1. Run the SQL Server container
podman run --name sql2025test -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=SqlTest123 -e MSSQL_PID=Developer -p 1433:1433 -d mcr.microsoft.com/mssql/server:2025-latest

Volume mapping

Possible solutions to persist the database data folder /var/opt/mssql/data outside the container:

Folder on Podman machine with full permissions (chmod 777):

podman run --name sql2025test -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=SqlTest123 -e MSSQL_PID=Developer -p 1433:1433 --volume /mypodmandata/shared/s1:/var/opt/mssql/data -d mcr.microsoft.com/mssql/server:2025-latest

Folder on Podman machine without full permissions but running sql-server as root user:

podman run --name sql2025test  -u 0:0  -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=SqlTest123 -e MSSQL_PID=Developer -p 1433:1433 --volume /mypodmandata/shared/s2:/var/opt/mssql/data -d mcr.microsoft.com/mssql/server:2025-latest

KO : at the moment this does not work, even with root user. Same behavior reported in Docker. Issue https://github.com/microsoft/mssql-docker/issues/948

podman run --name sql2025test -u 0:0 -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=SqlTest123 -e MSSQL_PID=Developer -p 1433:1433 --volume /mnt/c/Temp/PodmanShare/sql2025/data:/var/opt/mssql/data -d mcr.microsoft.com/mssql/server:2025-latest

Create database

Database can be created automatically when deploying with SqlPackage.exe (see next section) but for full control on mdf and ldf file names and location or in case of different deployment mode, the database can be created manually. E.g.:

CREATE DATABASE [TestDB] ON  PRIMARY 
( NAME = N'TestDB', FILENAME = N'/var/opt/mssql/data/TestDB.mdf' , SIZE = 10024KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10024KB )
LOG ON 
( NAME = N'TestDB_log', FILENAME = N'/var/opt/mssql/data/TestDB_log.ldf' , SIZE = 10024KB , MAXSIZE = 1GB , FILEGROWTH = 10024KB )
ALTER DATABASE [TestDB] SET RECOVERY SIMPLE WITH NO_WAIT

Deploy database

Starting from a Visual Studio SQL Server Database project, the database can be deployed and updated using:

  1. A schema comparision SCMP file
  2. Build a .dacpac file and deploy it with SqlPackage.exe

SCMP file

Create a schema comparison file (.scmp) in Visual Studio (Tools –> SQL Server –> New Schema Comparison…):

SqlPackage.exe

Install SqlPackage.exe if not already installed or use the one included with Visual Studio:

SET PATH=%PATH%;"C:\Program Files\Microsoft Visual Studio\18\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\"

Compile the database project to create the .dacpac file (e.g. mydb.dacpac) and then deploy using SqlPackage.exe:

SqlPackage.exe /action:publish /sourcefile:mydb.dacpac /TargetServerName:127.0.0.1 /TargetDatabaseName:mydb /TargetUser:sa /TargetPassword:SqlTest123 /TargetEncryptConnection:Optional /p:BlockOnPossibleDataLoss=True

To get a deployment report without applying changes:

SqlPackage.exe /action:deployreport /sourcefile:mydb.dacpac /TargetServerName:127.0.0.1 /TargetDatabaseName:mydb /TargetUser:sa /TargetPassword:SqlTest123 /TargetEncryptConnection:Optional /p:BlockOnPossibleDataLoss=True /OutputPath:report.xml

To get a drift report of the database:

SqlPackage.exe /action:driftreport  /TargetServerName:127.0.0.1 /TargetDatabaseName:mydb /TargetUser:sa /TargetPassword:SqlTest123 /TargetEncryptConnection:Optional  /OutputPath:report.xml