119
Deploying Applications to Windows Containers and Windows Server 2016 @Ben_Hall [email protected] OcelotUproar.com / Katacoda.com

Deploying applications to Windows Server 2016 and Windows Containers

Embed Size (px)

Citation preview

Page 1: Deploying applications to Windows Server 2016 and Windows Containers

Deploying Applications to Windows Containers and Windows Server 2016

@[email protected]

OcelotUproar.com / Katacoda.com

Page 2: Deploying applications to Windows Server 2016 and Windows Containers
Page 3: Deploying applications to Windows Server 2016 and Windows Containers
Page 4: Deploying applications to Windows Server 2016 and Windows Containers

Deploying Applications to Windows Containers and Windows Server 2016

@[email protected]

OcelotUproar.com / Katacoda.com

Page 5: Deploying applications to Windows Server 2016 and Windows Containers

@Ben_Hall / Blog.BenHall.me.uk

Docker London OrganiserMicrosoft MVP in Cloud / Datacentre Management

Software Development Studio

WH

O AM

I?

Page 6: Deploying applications to Windows Server 2016 and Windows Containers

Learn via Interactive Browser-Based LabsKatacoda.com

Page 7: Deploying applications to Windows Server 2016 and Windows Containers

Agenda• Windows Server 2016• Building and deploying Windows Containers• Differences to Linux• Hyper-V Containers• Docker API / Kubernetes / Swarm• Future

Page 8: Deploying applications to Windows Server 2016 and Windows Containers
Page 9: Deploying applications to Windows Server 2016 and Windows Containers

http://www.infoworld.com/article/3072929/linux/containers-101-linux-containers-and-docker-explained.html

Page 10: Deploying applications to Windows Server 2016 and Windows Containers

Containers are not Virtual Machines

Think of Docker more as a process management

Page 11: Deploying applications to Windows Server 2016 and Windows Containers

Docker - An open platform for distributed applications for developers and sysadmins.

Page 12: Deploying applications to Windows Server 2016 and Windows Containers

Batteries included but removable

Page 13: Deploying applications to Windows Server 2016 and Windows Containers

Three Key Concepts• Docker Containers – Running Processes

• Docker Images – “Layered Zip Files”

• Docker Registry – Where Images are stored

Page 14: Deploying applications to Windows Server 2016 and Windows Containers
Page 15: Deploying applications to Windows Server 2016 and Windows Containers
Page 16: Deploying applications to Windows Server 2016 and Windows Containers

http://windows-wallpapers.net/wp-content/uploads/images/1c/windows-98.png

2016

Page 17: Deploying applications to Windows Server 2016 and Windows Containers

Windows Server Core

Windows Nano

Windows Containers

Windows Hyper-V

Containers

Page 18: Deploying applications to Windows Server 2016 and Windows Containers

Windows Containers

Windows KernelWindows Server 2016

SQL Server MSMQ IIS /

ASP.NET Docker Engine

Page 19: Deploying applications to Windows Server 2016 and Windows Containers

Windows Hyper-V Containers

Windows Kernel

Windows Server 2016

SQL Server MSMQ IIS /

ASP.NET

Windows Kernel

Windows Utility VM

Hyper-V

Docker Engine

Page 20: Deploying applications to Windows Server 2016 and Windows Containers
Page 21: Deploying applications to Windows Server 2016 and Windows Containers

Windows Server Core• Nearly Win32 Compatible• Same behaviour of Windows• Install all of the same tooling

Page 22: Deploying applications to Windows Server 2016 and Windows Containers

Windows Nano• Stripped down• Smallest footprint• 1/20th the size of Windows Server Core• Only essential components– Hyper-V, Clustering, Networking, Storage, .Net,

Core CLR

Page 23: Deploying applications to Windows Server 2016 and Windows Containers

Windows Server Core => Ubuntu Linux

Windows Nano => Alpine Linux

Windows Server Core => Legacy Apps?

Windows Nano => Modern Apps?

Page 24: Deploying applications to Windows Server 2016 and Windows Containers

Installing Windows Containers

Page 25: Deploying applications to Windows Server 2016 and Windows Containers

> Install-Module -Name DockerMsftProvider \ -Repository PSGallery -Force> Install-Package -Name docker \ -ProviderName DockerMsftProvider> Restart-Computer -Force

Page 26: Deploying applications to Windows Server 2016 and Windows Containers
Page 27: Deploying applications to Windows Server 2016 and Windows Containers
Page 28: Deploying applications to Windows Server 2016 and Windows Containers

Layered Zip File

Page 29: Deploying applications to Windows Server 2016 and Windows Containers

Windows Linux Subsystem• Completely unrelated• Maybe not in the future…

Page 30: Deploying applications to Windows Server 2016 and Windows Containers

What is a Windows Docker Image?

Page 31: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker imagesREPOSITORY TAG IMAGE ID CREATEDwindowsservercore 10.0.10586.0 6801d964fda5 2 weeks ago windowsservercore latest 6801d964fda5 2 weeks ago nanoserver 10.0.10586.0 8572198a60f1 2 weeks ago nanoserver latest 8572198a60f1 2 weeks ago

Page 32: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker run -it \ windowsservercore cmd

Thank you to https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/manage_docker

Page 33: Deploying applications to Windows Server 2016 and Windows Containers

SSMS

Page 34: Deploying applications to Windows Server 2016 and Windows Containers

Building Windows based Docker Images

Page 35: Deploying applications to Windows Server 2016 and Windows Containers
Page 36: Deploying applications to Windows Server 2016 and Windows Containers
Page 37: Deploying applications to Windows Server 2016 and Windows Containers
Page 38: Deploying applications to Windows Server 2016 and Windows Containers
Page 39: Deploying applications to Windows Server 2016 and Windows Containers
Page 40: Deploying applications to Windows Server 2016 and Windows Containers
Page 41: Deploying applications to Windows Server 2016 and Windows Containers

Latest Tag• Official images have a convention of :latest

• Using :latest can introduces problems

• Use CI build number / Semver

Page 42: Deploying applications to Windows Server 2016 and Windows Containers
Page 43: Deploying applications to Windows Server 2016 and Windows Containers
Page 44: Deploying applications to Windows Server 2016 and Windows Containers

Dockerfile

Page 45: Deploying applications to Windows Server 2016 and Windows Containers

> type DockerfileFROM microsoft/windowsservercore:10.0.14393.693RUN powershell.exe Install-WindowsFeature web-server

> docker build –t iis .

Page 46: Deploying applications to Windows Server 2016 and Windows Containers
Page 47: Deploying applications to Windows Server 2016 and Windows Containers
Page 48: Deploying applications to Windows Server 2016 and Windows Containers

> type DockerfileFROM microsoft/iis:windowsservercore-10.0.14393.693SHELL ["powershell", "-command“]

Page 49: Deploying applications to Windows Server 2016 and Windows Containers

> type DockerfileFROM microsoft/iis:windowsservercore-10.0.14393.693SHELL ["powershell", "-command"]

RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install-WindowsFeature Web-Asp-Net45

Page 50: Deploying applications to Windows Server 2016 and Windows Containers

> type DockerfileFROM microsoft/iis:windowsservercore-10.0.14393.693SHELL ["powershell", "-command"]

RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install-WindowsFeature Web-Asp-Net45

RUN Remove-Website -Name 'Default Web Site'; \ mkdir c:\NerdDinner; \ New-Website -Name 'nerd-dinner' \ -Port 80 -PhysicalPath 'c:\NerdDinner' \ -ApplicationPool '.NET v4.5‘

Page 51: Deploying applications to Windows Server 2016 and Windows Containers

> type DockerfileFROM microsoft/iis:windowsservercore-10.0.14393.693SHELL ["powershell", "-command"]

RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install-WindowsFeature Web-Asp-Net45

RUN Remove-Website -Name 'Default Web Site'; \ mkdir c:\NerdDinner; \ New-Website -Name 'nerd-dinner' \ -Port 80 -PhysicalPath 'c:\NerdDinner' \ -ApplicationPool '.NET v4.5‘

EXPOSE 80

Page 52: Deploying applications to Windows Server 2016 and Windows Containers

> type DockerfileFROM microsoft/iis:windowsservercore-10.0.14393.693SHELL ["powershell", "-command"]

RUN Install-WindowsFeature NET-Framework-45-ASPNET; Install-WindowsFeature Web-Asp-Net45

RUN Remove-Website -Name 'Default Web Site'; \ mkdir c:\NerdDinner; \ New-Website -Name 'nerd-dinner' \ -Port 80 -PhysicalPath 'c:\NerdDinner' \ -ApplicationPool '.NET v4.5‘

EXPOSE 80

COPY NerdDinner c:\NerdDinner

Page 53: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker build –t nerddinner .

Page 54: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker run -d -p 80:80 \ nerddinner

Page 55: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker build –t nerddinner .

Page 56: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker run -d -p 80:80 \ nerddinner

Page 57: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker run -d -p 80:80 \ nerddinner

Page 58: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker run -d -p 80:80 \ --isolation=hyperv nerddinner

Page 59: Deploying applications to Windows Server 2016 and Windows Containers

ImmutableDisposable Container Pattern

Page 60: Deploying applications to Windows Server 2016 and Windows Containers

Windows Updates?

Page 61: Deploying applications to Windows Server 2016 and Windows Containers
Page 62: Deploying applications to Windows Server 2016 and Windows Containers

Persisting Data – Data Volumes

> docker run –v <host-dir>:<container-dir> image

-v C:\source:C:\dest

-v C:\container-share\config.ini

-v d:

-v C:\nerddinner\logs:C:\inetpub\logs\LogFiles

Page 63: Deploying applications to Windows Server 2016 and Windows Containers

Limit CPU Shares> docker run -it --cpu-shares 2 \ --name dockerdemo \ windowsservercore cmd

Page 64: Deploying applications to Windows Server 2016 and Windows Containers

Powershell APIPS C:\> Get-ContainerImageName Publisher Version IsOSImage---- --------- ------- ---------NanoServer CN=Microsoft 10.0.10584.1000 TrueWindowsServerCore CN=Microsoft 10.0.10584.1000 True

Page 65: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> New-Container -ContainerImageName WindowsServerCore -Name demo -ContainerComputerName demo

Name State Uptime ParentImageName---- ----- ------ ---------------demo Off 00:00:00 WindowsServerCore

Page 66: Deploying applications to Windows Server 2016 and Windows Containers

SQL Server Dependency

Page 67: Deploying applications to Windows Server 2016 and Windows Containers
Page 68: Deploying applications to Windows Server 2016 and Windows Containers

docker run --name nerddinnerdb -d -p 1433:1433 -e sa_password=password -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express

Page 69: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\>docker logs nerddinnerdb

Page 70: Deploying applications to Windows Server 2016 and Windows Containers

docker run --name nerddinnerdb -d -p 1433:1433 -e sa_password=p@sSw0rd1sl0ngY0 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express

Page 71: Deploying applications to Windows Server 2016 and Windows Containers

Docker Compose

Page 72: Deploying applications to Windows Server 2016 and Windows Containers

> cinst –y docker-compose

Page 73: Deploying applications to Windows Server 2016 and Windows Containers

> type docker-compose.yml

version: '2.1'networks: default: external: name: natservices: nerddinnerdb: image: microsoft/mssql-server-windows-express:2016-sp1-windowsservercore-10.0.14393.447 ports: - "1433:1433" environment: sa_password: "p@sSw0rd1sl0ngY0" ACCEPT_EULA: "Y"

nerddinnerweb: build: . ports: - "80:80" depends_on: - nerddinnerdb

> docker-compose up -d

Page 74: Deploying applications to Windows Server 2016 and Windows Containers
Page 75: Deploying applications to Windows Server 2016 and Windows Containers
Page 76: Deploying applications to Windows Server 2016 and Windows Containers
Page 77: Deploying applications to Windows Server 2016 and Windows Containers
Page 78: Deploying applications to Windows Server 2016 and Windows Containers

> type Dockerfile.windowsFROM microsoft/dotnet:1.0.0-preview2.1-nanoserver-sdk

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

RUN New-Item -Path \MusicStore\samples\MusicStore.Standalone -Type DirectoryWORKDIR MusicStore

ADD samples/MusicStore.Standalone/project.json samples/MusicStore.Standalone/project.jsonADD NuGet.config .RUN dotnet restore --no-cache .\samples\MusicStore.Standalone

ADD samples samplesRUN dotnet build .\samples\MusicStore.Standalone

EXPOSE 5000ENV ASPNETCORE_URLS http://0.0.0.0:5000CMD dotnet run -p .\samples\MusicStore.Standalone

https://github.com/taylorb-microsoft/MusicStore

Page 79: Deploying applications to Windows Server 2016 and Windows Containers

> type docker-compose.ymlversion: '2'services: db: image: microsoft/mssql-server-2016-express-windows environment: sa_password: "Password1" ports: - "1433:1433" # for debug. Remove this for production

web: build: context: . dockerfile: Dockerfile.windows environment: - "Data:DefaultConnection:ConnectionString=Server=db,1433;Database=MusicStore;User Id=sa;Password=Password1;MultipleActiveResultSets=True" depends_on: - "db" ports: - "5000:5000"

networks: default: external: name: nat

> docker-compose up –d --build

https://github.com/taylorb-microsoft/MusicStore

Page 80: Deploying applications to Windows Server 2016 and Windows Containers
Page 81: Deploying applications to Windows Server 2016 and Windows Containers

> docker tag nerddinner benhall/nerddinner:v2.0> docker push benhall/nerddinner:v2.0

Page 82: Deploying applications to Windows Server 2016 and Windows Containers

CI/CD PipelineGit Push Gitlab Starts

Build docker build

Gitlab Start Releasedocker push

Docker Compose Pull/Up

docker pull

Page 83: Deploying applications to Windows Server 2016 and Windows Containers

> cat .gitlab-ci.yml variables: IMAGE_NAME: registry.katacoda.com:4567/root/front-end TAG: $CI_BUILD_IDstages: - build - pushbuild_production: stage: build script: - docker build -t $IMAGE_NAME:$TAG . only: - masterpush_production: stage: build script: - docker push $IMAGE_NAME:$TAG only: - master

Page 84: Deploying applications to Windows Server 2016 and Windows Containers

How is this different to Linux?

Page 85: Deploying applications to Windows Server 2016 and Windows Containers

Kernel Virtualisation

Page 86: Deploying applications to Windows Server 2016 and Windows Containers

http://www.slideshare.net/Docker/windows-server-and-docker-the-internals-behind-bringing-docker-and-containers-to-windows-by-taylor-brown-and-john-starks

Page 87: Deploying applications to Windows Server 2016 and Windows Containers

http://www.slideshare.net/Docker/windows-server-and-docker-the-internals-behind-bringing-docker-and-containers-to-windows-by-taylor-brown-and-john-starks

Page 88: Deploying applications to Windows Server 2016 and Windows Containers

Windows Hyper-V Isolation

Page 89: Deploying applications to Windows Server 2016 and Windows Containers

Windows Hyper-V Isolation• Problem: Shared Kernel• Solution: Super lightweight virtual machines

• Intel Clear Containers• Ubuntu LXD• IBM are working on something

Page 90: Deploying applications to Windows Server 2016 and Windows Containers

PS C:\> docker run -it -p 80:80 \ --isolation=hyperv app cmd

1) Windows starts 'Utility VM‘ and freezes state2) Forks VM state, brings up a fresh second VM3) Launches container on VM

Page 91: Deploying applications to Windows Server 2016 and Windows Containers

Properties of Windows Utility VM• Invisible to Docker and containers• All writes are degraded• Separate Kernel to host• SMB file share to access host data

• In the future used for Linux containers?

Page 92: Deploying applications to Windows Server 2016 and Windows Containers

What about developers?

Page 93: Deploying applications to Windows Server 2016 and Windows Containers
Page 94: Deploying applications to Windows Server 2016 and Windows Containers

Install Containers Support on Windows 10> Enable-WindowsOptionalFeature -Online -FeatureName containers -All> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All> Restart-Computer -Force

> Invoke-WebRequest "https://test.docker.com/builds/Windows/x86_64/docker-1.13.0.zip" -OutFile "$env:TEMP\docker-1.13.0-rc4.zip" -UseBasicParsing> Expand-Archive -Path "$env:TEMP\docker-1.13.0.zip" -DestinationPath $env:ProgramFiles> dockerd --register-service> Start-Service Docker

Page 95: Deploying applications to Windows Server 2016 and Windows Containers

Docker for Windows

https://www.richard-banks.org/2016/09/docker-for-windows-beta-26.html

Page 96: Deploying applications to Windows Server 2016 and Windows Containers

Docker for Windows

https://www.richard-banks.org/2016/09/docker-for-windows-beta-26.html

Page 97: Deploying applications to Windows Server 2016 and Windows Containers

Docker for Windows

https://www.richard-banks.org/2016/09/docker-for-windows-beta-26.html

Page 98: Deploying applications to Windows Server 2016 and Windows Containers

Running Containers in Production

Page 99: Deploying applications to Windows Server 2016 and Windows Containers

Swarm

Page 100: Deploying applications to Windows Server 2016 and Windows Containers
Page 101: Deploying applications to Windows Server 2016 and Windows Containers

Constraint Scheduler$ docker run \ -e constraint:ostypelabel==windowscompat \ windowservercore cmd

$ docker run \ -e constraint:ostypelabel==linuxcompat \ ubuntu bash

Page 102: Deploying applications to Windows Server 2016 and Windows Containers
Page 103: Deploying applications to Windows Server 2016 and Windows Containers

Microsoft, Apprenda, Red Hathttps://github.com/kubernetes/kubernetes/issues/22623

Page 104: Deploying applications to Windows Server 2016 and Windows Containers

Mesosphere DC/OS

Powering Azure Container Service

Page 105: Deploying applications to Windows Server 2016 and Windows Containers

Host Fingerprinting• Constraints based deployment

• Container is based on Nano Server, within cluster, deploy to server capable of running Nano Server (ie. Windows Server 2016)Host Fingerprinting

Page 106: Deploying applications to Windows Server 2016 and Windows Containers
Page 107: Deploying applications to Windows Server 2016 and Windows Containers

Azure Container Service

Page 108: Deploying applications to Windows Server 2016 and Windows Containers
Page 109: Deploying applications to Windows Server 2016 and Windows Containers

The Future?

Page 110: Deploying applications to Windows Server 2016 and Windows Containers
Page 111: Deploying applications to Windows Server 2016 and Windows Containers

SQL Server as a Container

Page 112: Deploying applications to Windows Server 2016 and Windows Containers

Visual Studio as a Container?

Page 113: Deploying applications to Windows Server 2016 and Windows Containers

Everything as a Container

Page 114: Deploying applications to Windows Server 2016 and Windows Containers

Deploy Anywhere

Page 115: Deploying applications to Windows Server 2016 and Windows Containers

www.katacoda.com

Page 116: Deploying applications to Windows Server 2016 and Windows Containers
Page 117: Deploying applications to Windows Server 2016 and Windows Containers
Page 118: Deploying applications to Windows Server 2016 and Windows Containers

Next Steps• Katacoda

• Windows Server 2016 on Azure

• Windows 10

Page 119: Deploying applications to Windows Server 2016 and Windows Containers

Thank you!

@[email protected]

www.Katacoda.com