Sergiy Serdyuk - Fotolia
How SQL Server containers in Docker can ease database deployment
Docker containers can make the SQL Server deployment process more efficient and flexible. Here's what they are and how to get started on creating containers for SQL Server databases.
Starting with SQL Server 2017, you can run database instances in Docker containers on Linux systems in addition to the Windows ones supported in the 2016 version. Containers provide greater flexibility for implementing SQL Server and make the deployment process easier and faster.
However, getting started with SQL Server containers can be a confusing process, especially if it's your first time working with Docker or application containers in general.
Before trying to implement a SQL Server container, make sure you understand the components that go into supporting one. That includes not only the Docker platform, but also the host operating system (OS), the available Docker base images and the SQL Server edition you plan to run. Let's look at each piece of the containerization puzzle.
Docker is a platform for building and managing application containers. It's built on modular, open source technologies, making it easier for organizations to integrate Docker into their existing environments. The platform is available in two editions, Community and Enterprise, with installation paths available to a mix of Linux, Windows and Mac hosts.
Lead developer Docker Inc. offers the Community Edition as a free download that includes the container engine and the tools necessary to develop, test and run containerized applications. There are two versions of the Community Edition: Edge, which contains the newest features and is updated every month, and Stable, a more reliable release that's updated quarterly.
Also updated each quarter, the Enterprise Edition is what Microsoft supports for running SQL Server containers. It builds on the Community Edition by adding features for managing container images and running security scans on them, plus container application management and other capabilities.
What a Docker container contains
At the heart of all Docker implementations is the container, a lightweight, stand-alone package for executing a piece of software. The container includes everything the software needs to run, including the application code, system libraries, as well as its own runtime, configuration settings and system tools.
Despite its self-contained nature, a container is still dependent on the underlying OS. The container isolates a portion of the host's kernel resources, such as processor and memory, and allocates them to the containerized software, providing a virtualized environment at the OS level. In this way, the software is segregated from other processes, while still being able to interface with the host system; that enables multiple containerized applications to run on the same server, but isolated from one another.
Containers also make it easier to move applications from host to host. For example, a container can be moved from a developer's computer to a test server and then on to a production system, whether that's in house or in the cloud. Additionally, containers make it possible to more easily implement software across multiple servers to help accommodate fluctuating and distributed workloads and evolving data center architectures.
Although a container represents a type of virtualization, it is much different than a virtual machine (VM). As outlined in the chart below, a container shares more of the host system's resources than a VM does; consequently, it requires fewer dedicated resources, making it more lightweight, easier to set up and quicker to create, clone and start. That results in greater portability and more efficient resource usage.
Docker containers and SQL Server
Windows Server 2016 was the first Windows OS to support Docker containers, initially making it possible to run SQL Server 2016 in a container on a Windows system. SQL Server containers are essentially named instances that can be easily and quickly created, deleted and moved, making them ideal for development and test teams, particularly when it comes to such practices as DevOps and continuous integration.
Production environments also stand to benefit from the portability and flexibility that containers offer, including cloud-based environments built on multi-tenant architectures. However, SQL Server containers are a relatively new technology, and most organizations appear to still be testing the waters, although the addition of Linux support in SQL Server 2017 could prove to be a game-changer for container adoption.
Like other Docker containers, a SQL Server container typically starts with a predefined image on which it's based. The Docker Hub public repository offers both Windows- and Linux-based SQL Server 2017 container images.
The default image for SQL Server on Linux is based on the free Developer Edition of the database software and implemented on top of an Ubuntu 16.04 OS base image; however, if you have valid licenses, you can implement production container images pulled from the Docker Store for other SQL Server editions. The Developer Edition image can be run on Docker Engine on Linux, Windows and macOS systems to build SQL Server containers; Microsoft has also made Dockerfiles available on GitHub for users who want to create similar SQL Server images based on the CentOS and Red Hat Enterprise Linux distributions of Linux instead of Ubuntu.
Microsoft provides Windows-based SQL Server 2017 images for both the Developer Edition and the also free Express Edition. You can use these images to create containers only with the Windows version of Docker. There's also a Windows Server core image on which you can install any edition of SQL Server for Windows -- again, assuming you have the proper licenses.
Not surprisingly, there's much more to working with Docker containers than what we've covered here. You need to install and configure the Docker platform, pull at least one base image into your environment and then create the container before you can actually start using SQL Server.
Even so, the process is much simpler and faster than a traditional SQL Server installation once you understand how all the pieces fit together. And when a SQL Server container is up and running, you can access it just like any other SQL Server instance. You can even connect from SQL Server Management Studio, providing you with a great way to try out SQL Server 2017 without affecting your current SQL Server environment or installations.