How To Run Microsoft SQL On Window Containers

In this blog post, I’ll show you how I install and configure Microsoft SQL Server on Windows Containers and Docker.

My environment, Is built of Windows Server 2016 Container host running on Azure with the latest Docker Enterprise Edition.

Requirements

To run SQL, I’ll need to download the MS SQL Express Container Image and Install Management Studio either on my Container Host or a management machine.

Note that the SQL Server Image runs on Windows Server Core Container Image with 7GB download size and 11GB on disk once downloaded.

For more information on the SQL Container Image visit.

https://hub.docker.com/r/microsoft/mssql-server-windows-express/tags/

Download Image

To download the SQL image container I’ll use the line below

docker pull microsoft/mssql-server-windows-express

Next, I’ll download the Microsoft SQL Server Management Studio and Install It on my machine

https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms

Now that I have my Container Image and Management studio Installed I’ll spin my Docker Container with SQL.

Run SQL Container

Below Is my Docker Run line which will start a new container with port 1433 open with the name sql01 and set the SA password (make sure you upper case, number, and special character), Set storage on the host (used to host the database).

docker container run -d -p 1433:1433 --name sql01 -e sa_password=password1 -e ACCEPT_EULA=Y -v c:\sqldb\c:data microsoft/mssql-server-windows-express

To view, If the container started OK, I’ll run the logs cmdlet to make sure the password was set correctly

docker container logs sql01

To get my Container IP address, I’ll run the line below

Docker exec sql01 ipconfig

Connect to SQL Container

Now that my container Is running OK, I’ll start Management Studio and use the IP address, username, password and SQL Server

Once connected, I’ll create a new database and place inside c:\data which is mapped to my Container host c:\sqldb.

Because I’m using a mapped volume on the host to store my database, I don’t need to worry about deleting the container because my data Is on the host.

As you can see below, the new database Is saved on my C:\SQLDB located on the container host

Conclusion

Using SQL with Windows Containers Is great for test, development and production environment.


Posted

in

by

Comments

One response to “How To Run Microsoft SQL On Window Containers”

  1. Panos Tz Avatar
    Panos Tz

    A small edit on your run command(volume bind command):

    docker container run -d -p 1433:1433 –name sql01 -e sa_password=password1 -e ACCEPT_EULA=Y -v c:\sqldb:c:\data microsoft/mssql-server-windows-express