Having SQL Server on a Docker container is one of the best ideas I discovered; not only to keep my computer always clean, but also for performance and the ability to start again and again from scratch my testings; very very easy and fast.

This time I wanted to test SQL Server 2019 on Linux Red Hat; the results didn’t disappoint me at all. Also, I tested Azure Data Studio; a cross-platform database tool; previously released as the preview name SQL Server Studio

Let’s see how was the process:

Prerequisites to run SQL Server image with Docker

  • Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows. For more information, see Install Docker.
  • Docker overlay2 storage driver. This is the default for most users. If you find that you are not using this storage provider and need to change, please see the instructions and warnings in the docker documentation for configuring overlay2.
  • Minimum of 2 GB of disk space.
  • Minimum of 2 GB of RAM.

Preparing the environment

Downloading Docker image

Once Docker up and running at my system, I downloaded docker image:

docker pull mcr.microsoft.com/mssql/rhel/server:2019-CTP2.2

Running RHEL Docker

After downloaded, started a container

docker run -e "ACCEPT_EULA=Y" -e "PASSWORD=Passw0rd" -p 1433:1433 --name sql01 -d mcr.microsoft.com/mssql/rhel/server:2019-CTP2.2

Let’s check everything is Ok, into the container:

docker exec -it sql01 "bash"
cat /etc/os-release
ls -la

Left a new directory in the container, just to drop the db

mkdir /var/opt/mssql/backup

Downloaded a test db to play with

Just for testing, I downloaded from PowerShell test db

curl -OutFile "wwi.bak" https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak

And copied it into RHEL Docker container:

docker cp .\wwi.bak sql01:/var/opt/mssql/backup

Restored the db

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Passw0rd" -Q "RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/wwi.bak'"

And after restored backup file, restore db was needed

docker exec -it sql01 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<YourNewStrong!Passw0rd>" -Q "RESTORE DATABASE WideWorldImporters FROM DISK = '/var/opt/mssql/backup/wwi.bak' WITH MOVE 'WWI_Primary' TO '/var/opt/mssql/data/WideWorldImporters.mdf', MOVE 'WWI_UserData' TO '/var/opt/mssql/data/WideWorldImporters_userdata.ndf', MOVE 'WWI_Log' TO '/var/opt/mssql/data/WideWorldImporters.ldf', MOVE 'WWI_InMemory_Data_1' TO '/var/opt/mssql/data/WideWorldImporters_InMemory_Data_1'"

Azure Data Studio

After downloaded Azure Data Studio (I do prefer the “zip” version, as I can leave it in the cloud), everything was accesible

Nice and easy one!


Leave a Reply

%d bloggers like this: