Running MS SQL in a docker container
As a little exercise, I was setting up a local MS SQL database in a Docker container. I have used Microsoft SQL Server during my time at comparis.ch. It is a powerful database system and integrates nicely with the rest of the .NET toolchain.
Setting up the container
Microsoft provides a well-documented way to start a developer-mode container with a database server.
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<password>" \
-p 1433:1433 --name sql1 --hostname sql1 \
-d \
mcr.microsoft.com/mssql/server:2025-latest
Connecting with DBeaver
To take a look, I have used DBeaver to connect to my newly created database. A connector for Microsoft SQL Server is existing, use localhost as host, master as database and the password provided for the container.
But there is not so much happening right there. So we need some data to fill it up. To follow along the Microsoft documentation, the AdventureWorks sample database is a good start, provided at microsoft/sql-server-samples. I chose the oltp-install-script folder, which contains the instawdb.sql install script.
Unfortunately we cannot execute this script in DBeaver, as it requires the SQLCMD mode. So one more step to takeā¦
Installing sqlcmd
Following the installation instructions for Linux, we can install the sqlcmd tool.
Running the database setup script
sqlcmd -S localhost -U user -P <password> -C -i instawdb.sql
The parameter -C trusts the server certificate, which should do for local testing purposes. But there is one problem, the bulk import does not work, as files are not found. The important catch here is that those files must exist inside of the container.
Copy the CSV files into the container
for f in *.csv; do
podman cp $f sql1:/var/opt/mssql/backup
done
And now we can finally adjust the samples source path in instawdb.sql and rerun the script.
:setvar SqlSamplesSourceDataPath "/var/opt/mssql/backup/"
The bulk import is now working and we have our test database ready.