Welcome to… An Introduction to SQL Server & Containers
SAY THANK YOU TO OUR SPONSORS!
Sponsor Raffle!!! Each sponsor stamp will opt you into their raffle prize and mailings Collect 9+ sponsor stamps on your Badge to be eligible for the Xbox Hand entire Badge/ ribbon back into registration desk at end of day We will draw Badges for prizes at 5pm in Cromwell (if you are drawn and do not have the pre-requisite stamp/s….. You lose!) SQLCloud: XBox One-S with Forza Horizon 3 Bundle; Amazon Fire TV with 4K Ultra HD; Raspberry Pi 3 Starter Kit; dbWatch: Apple iPad Mini; Skybow: Marshall Speaker; Coeo: A free place on any Coeo training course, RRP £600; Edison365: Helicopter ride (lunchtime session prize) and a Fire TV Stick; Pyramid Analytics: Amazon Echo; Quest: Samsung Gear S2 Smartwatch; DBPro/ SQLGovernor: Splash-proof JBL bluetooth speaker; Redgate: SQL Monitor License - with 12 months support and upgrades; Axioworks: Amazon Echo Dot; Idera: $100 Amazon card; Lightning Tools: Lego Technics Race Car; SQL Sentry: SQL Sentry license and 1 year of support (worth $2994); Locke Data: R for Data Science: Import, Tidy, Transform, Visualize, and Model Data; SharePoint Unite /BMM Media: A free pass to SharePoint Unite 2017 conference in Haarlem, Netherlands, on the 25th & 26th October. worth €699. travel and hotel not included; PASS: Recording (download) of all sessions from PASS Summit 2016
Social Make sure you tweet on #spscambridge or #sqlsatcambridge During the event we have Giant Jenga, Sack races and Conker Fights! After event, join us for a post event SharePint/ SQLPint from our bar Don’t forget to thank Sponsors, Volunteers and Speakers! The event will close at 6.30pm
Andrew Pruski @DBAFromTheCold dbafromthecold@gmail.com www.dbafromthecold.com SQL Server DBA for 6 years Working with RDBMS for ~10 years Working with containers for about two years now Originally from Wales, now living in Dublin
Session Aim To give you a base of knowledge to be able to start to experimenting with containers
Docker & Microsoft Announced partnership in 2014 http://news.microsoft.com/2014/10/15/DockerPR/ Containers supported in Windows Server 2016 & Windows 10 Anniversary Edition
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
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. https://www.docker.com/what-docker
Container fundamentals Container Host Container Engine Container Registry Container Images
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
Virtual Machines vs Containers
Container Networking
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
Cons Only the database engine is supported 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?
Getting started
Installing the Docker engine Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 –Force Install-Module -Name DockerMsftProvider –Force Install-Package -Name docker -ProviderName DockerMsftProvider –Force Restart-Computer -Force
Containers server feature enabled
Docker Engine Service Get-Service docker docker version
Azure Custom image available with container role enabled and docker engine installed
Windows 10 Download .msi https://store.docker.com/
Linux - Ubuntu https://docs.docker.com/engine/installation/linux/docker-ee/ubuntu/#install- using-the-repository git clone https://github.com/dbafromthecold/InstallDockerOnUbuntu.git cd InstallDockerOnUbuntu chmod +x installdocker.sh ./installdocker.sh
Demo
Creating your first container
Search the Docker repository docker search microsoft/mssql
Pull an image docker pull microsoft/mssql-server-windows
Verify the image docker images
Create container from image docker run –d –p 15789:1433 --env ACCEPT_EULA=Y --env SA_PASSWORD=Testing11@@ --name MyFirstContainer microsoft/mssql-server-windows
Verify container is running docker ps [-a]
Connecting to your container - locally docker inspect MyFirstContainer
Connecting to your container - remotely
Demo
Using DockerFiles
DockerFiles A file on the docker host that contains commands that create a custom image
Dockerfile code FROM microsoft/mssql-server-windows RUN powershell -Command (mkdir C:\\SQLServer) COPY DatabaseA.mdf C:\\SQLServer COPY DatabaseA_log.ldf C:\\SQLServer ENV SA_PASSWORD=Testing11@@ ENV ACCEPT_EULA=Y ENV attach_dbs="[{'dbName':'DatabaseA','dbFiles':['C:\\SQLServer\\DatabaseA.mdf','C:\\SQLServer\\DatabaseA_log.ldf']}]"
Building image from a Dockerfile docker build –t myfirstimage .
Verify new custom image docker images
Creating container from custom image docker run –d –p 15777:1433 --name MyCustomContainer myfirstimage
Database within custom container
Demo
Sharing images
Sharing images locally docker save –o myexportedimage.tar myfirstimage
Importing images docker load -i myexportedimage.tar
The Docker Hub https://hub.docker.com
Creating your repository
Tagging an image docker tag myfirstimage dbafromthecold/testsqlrepository:v1
Log in to Docker hub docker login
Pushing to the Docker Hub docker push dbafromthecold/testsqlrepository:v1
Viewing pushed image in Docker Hub
Demo
Case Study
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
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
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 www.windocks.com/leads/add?src=downloadcommunity
Architecture
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
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
Other Resources
Other SQL Images https://github.com/dbafromthecold/ On the Docker Hub docker search dbafromthecold/sqlserver2012dev docker search dbafromthecold/sqlserver2014dev Code on GitHub https://github.com/dbafromthecold/
Portainer http://portainer.io/ Open source UI Available on Docker Hub
Further Information Summary of Container Series https://dbafromthecold.com/2017/03/15/summary-of-my-container-series/ Case Study on SQLServerCentral.com http://www.sqlservercentral.com/articles/containers/154337/ Podcast with SQL Data Partners http://sqldatapartners.com/2017/01/24/sql-server-containers/ Docker on Windows Server Core https://www.sqlshack.com/running-sql-server-containers-windows-server-2016-core/
Questions?