Download presentation
Presentation is loading. Please wait.
1
Andrew Pruski - @dbafromthecold SQL Server & Containers
An introduction to SQL Server & Containers
2
PREMIER SPONSOR GOLD SPONSORS SILVER SPONSORS BRONZE SPONSORS
BRONZE SPONSORS SUPPORTERS
3
Friendly meetup for data professionals in Bristol
4
Andrew Pruski @DBAFromTheCold dbafromthecold@gmail.com
SQL Server DBA for 6 years Working with RDBMS for ~10 years Working with containers for ~2 years Originally from Wales, now living in Dublin
5
Session Aim To give you a base of knowledge to be able to start to experimenting with containers
6
Agenda Container theory Setup of Windows Server 2016 for containers Building your first container Creating a custom container image Exporting a custom image Pushing custom image to the Docker Hub Implementing containers – case study
7
Container Definition Containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.
8
Container fundamentals
Container Host Container Engine Container Registry Container Images
9
Container Types Windows Server Containers Hyper-V containers
Isolation provided through namespace, resource & process isolation Share kernel with host and other containers Hyper-V containers Expand on isolation from windows server containers Run inside of a specialised virtual machine Does not share a kernel with host Specified at runtime with --isolation=hyperv switch
10
Virtual Machines vs Containers
11
Container Networking
12
Pros Simple and fast setup New containers can be spun up in seconds
Relatively low footprint compared to VMs Ability to customise images Access to Docker repository (hundreds of images available) Portability, images can be saved to the Docker Hub
13
Cons Only the database engine is supported No windows authentication
Only supported on Windows Server 2016 / Windows 10 Anniversary Edition Official SQL Server images for 2016 & 2017 only SQL images aren't the smallest (~13GB) Suitability for production?
14
Getting started
15
Installing the Docker engine
Install-Module -Name DockerMsftProvider –Force Install-Package -Name docker -ProviderName DockerMsftProvider Restart-Computer -Force
16
Containers server feature enabled
17
Docker Engine Service Get-Service docker docker version
18
Azure Custom image available with container role enabled and docker engine installed
19
Windows 10 Download .msi
20
Linux - Ubuntu using-the-repository git clone cd InstallDockerOnUbuntu chmod +x installdocker.sh ./installdocker.sh
21
Demo
22
Creating your first container
23
Search the Docker repository
docker search microsoft/mssql
24
Pull an image docker pull microsoft/mssql-server-windows
25
Verify the image docker images
26
Create container from image
docker run –d –p 15789:1433 ` --env ACCEPT_EULA=Y --env ` --name MyFirstContainer microsoft/mssql-server-windows
27
Verify container is running
docker ps [-a]
28
Connecting to your container - locally
docker inspect MyFirstContainer
29
Connecting to your container - remotely
30
Demo
31
Using DockerFiles
32
DockerFiles A file on the docker host that contains commands that create a custom image
33
Dockerfile code FROM microsoft/mssql-server-windows RUN mkdir C:\\SQLServer COPY DatabaseA.mdf C:\\SQLServer COPY DatabaseA_log.ldf C:\\SQLServer ENV ENV ACCEPT_EULA=Y ENV attach_dbs="[{'dbName':'DatabaseA','dbFiles':['C:\\SQLServer\\DatabaseA.mdf','C:\\SQLServer\\DatabaseA_log.ldf']}]"
34
Building image from a Dockerfile
docker build –t myfirstimage .
35
Verify new custom image
docker images
36
Creating container from custom image
docker run –d –p 15777: name MyCustomContainer myfirstimage
37
Database within custom container
38
Demo
39
Sharing images
40
Sharing images locally
docker save –o myexportedimage.tar myfirstimage
41
Importing images docker load -i myexportedimage.tar
42
The Docker Hub
43
Creating your repository
44
Tagging an image docker tag myfirstimage dbafromthecold/testsqlrepository:v1
45
Log in to Docker hub docker login
46
Pushing to the Docker Hub
docker push dbafromthecold/testsqlrepository:v1
47
Viewing pushed image in Docker Hub
48
Demo
49
Data Persistence
50
Mounted volumes docker run -d -p 15789:1433 `
-v C:\SQLServer:C:\SQLServer ` --env ACCEPT_EULA=Y --env ` --name testcontainer microsoft/mssql-server-windows
51
Named volumes docker create volume sqlserver
docker run -d -p 16789:1433 ` --env ACCEPT_EULA=Y --env ` -v sqlserver:C:\sqlserver ` --name testcontainer microsoft/mssql-server-windows
52
Data volume containers
docker create -v C:\SQLServer --name datastore microsoft/windowsservercore docker run -d -p 16789:1433 ` --env ACCEPT_EULA=Y --env ` --volumes-from datastore ` --name testcontainer microsoft/mssql-server-windows
53
Demo
54
Case Study
55
Problem QA/Dev departments repeatedly creating new VMs
All VMs require a local instance of SQL Server SQL installed from chocolately 30+ databases then restored from baselines via PoSH scripts SQL install taking ~40 minutes from start to finish
56
Solution Containers! Implement containers running SQL Server for new VMs SQL containers built from custom image No longer need to install SQL No longer need to restore databases Resources freed up on VMs
57
WinDocks www.windocks.com
A port of the open source project from Docker Inc. Software supports the creation of containers running earlier versions of SQL Server (2008+) on Windows Server 2012 Free Community Edition available
58
Architecture
59
Benefits New VMs deployed in a fraction of the previous time
No longer need to run PoSH scripts to restore databases Base image can be used to keep containers at production SQL instance’s patch level More VMs can be provisioned on host due to each VM requiring less resources
60
Issues Apps using DNS entries to reference local SQL instance
Update to existing test applications Trial and error to integrate with Octopus deploy New ways of thinking
61
Other Resources
62
Other SQL Images https://github.com/dbafromthecold/ On the Docker Hub
docker pull dbafromthecold/sqlserver2012dev:sp3 docker pull dbafromthecold/sqlserver2014dev:sp2 docker pull dbafromthecold/sqlserverlinuxagent:2017-GA Code on GitHub
63
Further Information Summary of Container Series
Case Study on SQLServerCentral.com Podcast with SQL Data Partners Docker on Windows Server Core
64
Questions?
65
SQLRelay.co.uk/feedback
Live Now Win a Lego BB8!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.