Microsoft have an image on Docker Store which lets you run SQL Server Express 2016 as a container: microsoft/mssql-server-windows-express. That gives you a vanilla SQL Server instance where you can attach existing databases, but you need to have created the database outside of the container first. In this lab we'll build a Docker image which packages up a whole database schema, so when you run the container you have a fully-deployed database ready to use from your applications, or from SQL Server Management Studio.
You'll learn how to:
-
use the Docker Builder pattern with SQL Server, running a Docker container as an agent to build a database project and generate a database deployment Dacpac file;
-
build a Docker image which packages up SQL Server Express together with your Dacpac, and configured to deploy the database when you run a container;
-
run the database container with a Docker volume, so the data files are stored outside the container;
-
upgrade the database by building a new image with an updated schema, then replacing the existing container, using the same Docker volume to preserve data.
You'll need Docker running on Windows. You can follow the Windows Container Lab Setup to install Docker on Windows 10, or Windows 2016 - locally, on AWS and Azure.
You should be familiar with the key Docker concepts, and with Docker volumes:
We'll be using SQL Server Data Tools ("SSDT") to build the database schema into a deployable package. An understanding of SSDT and Dacpacs will be useful:
The build process using Docker does not use Visual Studio, but if you want to view or edit the SQL Database project yourself, you'll need Visual Studio 2015. The free Visual Studio Community Edition comes with SQL Server Data Tools.