/rob_rich

Database DevOps
with Containers

by Rob Richardson

/rob_rich

https://robrich.org/

About Me

Rob Richardson

Rob Richardson is a software craftsman building web properties in ASP.NET and Node, React and Vue. He's a frequent speaker at conferences, user groups, and community events, and a diligent teacher and student of high quality software development. You can find this and other talks on https://robrich.org/presentations and follow him on twitter at @rob_rich.

Goals of DevOps

Automate all the things

Because computers are cheaper than people

DevOps Pipeline

DevOps Pipeline for Apps


suggestion

check out

code

build

test

deploy

qa

prod

feedback
Icons: Icons8 and Font Awesome

DevOps Pipeline for Apps


suggestion

check out

code

build

test

deploy

qa

prod

feedback
Icons: Icons8 and Font Awesome

DevOps Pipeline for Apps

Where is the primary copy?


suggestion

check out

code

build

test

deploy

qa

prod

feedback
Icons: Icons8 and Font Awesome

DevOps Pipeline for Apps DBs?

Where is the primary copy?


suggestion

check out

code

build

test

deploy

qa

prod

feedback
Icons: Icons8 and Font Awesome

DevOps Pipeline for Databases


developer

dev/test

pre-prod

prod

Icons: Icons8 and Font Awesome

DevOps Pipeline for Databases


developer

dev/test

pre-prod

prod

Icons: Icons8 and Font Awesome

DevOps Pipeline for Databases


developer

dev/test

pre-prod

prod

Icons: Icons8 and Font Awesome

DevOps Pipeline for Databases


developer

dev/test

pre-prod

prod

Icons: Icons8 and Font Awesome

DevOps Pipeline for Databases


developer

dev/test

pre-prod

prod

Icons: Icons8 and Font Awesome

DevOps Pipeline for Databases

Tweaked for each environment:

  • anonymize
  • sanitize
  • shrink
  • migrate to latest version
  • validate

DevOps Goals

Automate all the things

How can we automate this?

with Docker containers

Docker

Docker

What are containers?

How do I build them in an automated way?

How is this better than VMs / Puppet / Chef?

"Docker: VM++"

What is Docker?

Docker is an ecosystem around Container Virtualization

What are Containers?

Light-weight kernel virtualization

What is Docker?

A suite of command-line tools for
creating, running, and sharing containers

Containers vs VMs

vm vs container

Source: http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/

Containers

virtualize and share the host kernel

must match host kernel:

  • Linux containers run on a Linux host
  • Windows Server containers run on a Windows Server host

Host Docker in a VM

docker nested in a vm

Docker Ecosystem

docker ecosystem

Download: https://robrich.org/slides/welcome-to-docker/docker-ecosystem.pdf

Devs build Images

FROM microsoft/dotnet:2.1-aspnetcore-runtime

WORKDIR /app

COPY Site.csproj .
RUN dotnet restore

COPY . .

RUN dotnet build -c Release
RUN dotnet publish -c Release -o dist

WORKDIR /app/dist

ENV ASPNETCORE_URLS http://+:5000
EXPOSE 5000
CMD ["dotnet", "Site.dll"]

DEMO: Docker hub dependencies

Layered Filesystem

source

  • read/write layer
  • demo
    • CMD ["dotnet" "Site.dll"]
    • EXPOSE 5000
    • ENV ASPNETCORE_URLS http://+5000
    • RUN dotnet publish
    • RUN dotnet build
    • RUN dotnet restore
  • ASP.NET
    • Install ASP.NET runtime
    • Install curl
  • .NET Runtime
    • ... steps ...
  • parent image
    • ... steps ...
  • parent image
    • ... steps ...

Docker Magic

Inside the Container:

  • A machine
  • Unique IP, hostname
  • Build your perfect snowflake
 

Outside the Container:

  • A process
  • Plug in power and internet
  • Restart quickly
  • Scale by launching more

SQL Server

DEMO: SQL Server DevOps