For flexibility and version management, we run Microsoft SQL Server in a Docker container, hosted inside a Linux System Container (LXC).
Why LVM? SQL Server on Linux requires
ext4orXFSfilesystems. It does not supportbtrfs(the default Incus storage driver). We create a dedicated LVM storage pool for the SQL database files.
Create a dedicated LVM pool.
# storage.yaml
name: data
description: For SQL-Server (XFS/ext4)
driver: lvm
config:
lvm.thinpool_name: IncusThinPool
lvm.vg_name: data
size: 600GiB
source: /var/lib/incus/disks/data.imgApply: incus storage create -f storage.yaml (or via UI)
We create an Ubuntu container (gipDLVmSQL1) and attach the storage.
# Launch container
sudo incus launch ubuntu:24.04 gipDLVmSQL1 -c security.nesting=true
# Add the dedicated data volume
sudo incus storage volume create data SQLData size=600GiB
sudo incus config device add gipDLVmSQL1 disk-device-1 disk pool=data source=SQLData path=/data
# Add shared folder (optional, for backups)
sudo incus config device add gipDLVmSQL1 disk-device-2 disk source=/home/damir/SHARED path=/SHAREDLog into the container:
sudo incus exec gipDLVmSQL1 bashInside the container:
apt update && apt install docker.io -yWe use Docker to run specific versions of SQL Server (e.g., 2019, 2022) side-by-side using different ports or separate containers.
-
Prepare Directories:
mkdir -p /data/2019/data mkdir -p /data/2019/bak
-
Run Container:
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" \ -p 1433:1433 --name sql2019 \ -v /data/2019/data:/var/opt/mssql \ -v /data/2019/bak:/var/backups \ -d mcr.microsoft.com/mssql/server:2019-latest
-
To automatically start a container
docker update --restart always sql2019
Change SA Password (if needed):
docker exec -it sql2019 /opt/mssql-tools18/bin/sqlcmd \
-C -S localhost,1433 -U sa \
-P "OLD_PASSWORD" \
-Q "ALTER LOGIN sa WITH PASSWORD='NEW_PASSWORD'"Stop/Start/Remove:
docker stop sql2019
docker start sql2019
docker rm sql2019With this setup, your SQL Server data resides on the fast, compatible LVM volume /data, while the engine runs effectively in a disposable Docker container.