Top Banner
Deploying Docker Containers on Windows Server 2016 @Ben_Hall [email protected] OcelotUproar.com / Katacoda.com
82

Deploying Windows Containers on Windows Server 2016

Jan 06, 2017

Download

Technology

Ben Hall
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Deploying Windows Containers on Windows Server 2016

Deploying Docker Containers on Windows Server 2016

@[email protected]

OcelotUproar.com / Katacoda.com

Page 2: Deploying Windows Containers on Windows Server 2016

@Ben_Hall / Blog.BenHall.me.uk

Tech Support > Tester > Developer > Founder

Software Development Studio

WH

O AM

I?

Page 3: Deploying Windows Containers on Windows Server 2016

https://www.katacoda.com/

Page 4: Deploying Windows Containers on Windows Server 2016

Agenda

• Introduction to Docker• Windows Containers• Deploying IIS / ASP.NET with Containers• Running containers in Production• Future

Page 5: Deploying Windows Containers on Windows Server 2016

doger.io

Page 6: Deploying Windows Containers on Windows Server 2016
Page 7: Deploying Windows Containers on Windows Server 2016

https://www.docker.com/whatisdocker/

Container

Page 8: Deploying Windows Containers on Windows Server 2016

Own Process SpaceOwn Network InterfaceOwn Root Directories

Sandboxed

Like a lightweight VM. But it’s not a VM.

Page 9: Deploying Windows Containers on Windows Server 2016

Native CPUNative Memory

Native IO

No Pre-AllocationNo Performance Overheard

Page 10: Deploying Windows Containers on Windows Server 2016

Milliseconds to launch

Still fully isolated

Page 11: Deploying Windows Containers on Windows Server 2016

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

Page 12: Deploying Windows Containers on Windows Server 2016

Got us to agree on something!

Page 13: Deploying Windows Containers on Windows Server 2016
Page 14: Deploying Windows Containers on Windows Server 2016

Batteries included but removable

Page 15: Deploying Windows Containers on Windows Server 2016

Linux cgroups & namespaces

Page 16: Deploying Windows Containers on Windows Server 2016
Page 17: Deploying Windows Containers on Windows Server 2016

> docker run –p 6379:6379 redis _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.3 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'

1:M 05 Nov 10:42:24.402 # Server started, Redis version 3.0.31:M 05 Nov 10:42:24.402 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.1:M 05 Nov 10:42:24.402 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.1:M 05 Nov 10:42:24.403 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.1:M 05 Nov 10:42:24.403 * The server is now ready to accept connections on port 6379

Page 18: Deploying Windows Containers on Windows Server 2016

RStudio> docker run -d -p 8787:8787 rocker/rstudio

Page 19: Deploying Windows Containers on Windows Server 2016

Windows?

Page 20: Deploying Windows Containers on Windows Server 2016

Windows Server 2016

• Currently TP4• TP5 is coming “very soon”

• RTM in Q3ish

Page 21: Deploying Windows Containers on Windows Server 2016

Windows Server Core

Windows Nano

Windows Containers

Windows Hyper-V

Containers

Page 22: Deploying Windows Containers on Windows Server 2016

Windows Containers

Windows Kernel

Windows Server 2016

SQL Server MSMQ IIS /

ASP.NET

Docker Engine

Page 23: Deploying Windows Containers on Windows Server 2016

Windows Hyper-V Containers

Windows Kernel

Windows Server 2016

SQL Server MSMQ IIS /

ASP.NET

Windows Kernel

Windows Server 2016

Hyper-V

Docker Engine

Page 24: Deploying Windows Containers on Windows Server 2016
Page 25: Deploying Windows Containers on Windows Server 2016

Windows Server Core

• Nearly Win32 Compatiable• Same behaviour of Windows• Install all of the same tooling

Page 26: Deploying Windows Containers on Windows Server 2016

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 27: Deploying Windows Containers on Windows Server 2016

Windows Server Core => Ubuntu Linux

Windows Nano => Alpine Linux

Windows Server Core => Legacy Apps?

Windows Nano => Modern Apps?

Page 28: Deploying Windows Containers on Windows Server 2016

Work In Progress

• https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/work_in_progress

• eg: Windows Containers cannot be managed/interacted with through a RDP session in TP4.

Page 29: Deploying Windows Containers on Windows Server 2016

Installing Windows Containers

Page 30: Deploying Windows Containers on Windows Server 2016

C:\> Install-WindowsFeature containers

C:\> wget https://aka.ms/tp4/docker -OutFile $env:SystemRoot\system32\docker.exe

C:\> start-process nssm install

Page 31: Deploying Windows Containers on Windows Server 2016
Page 32: Deploying Windows Containers on Windows Server 2016
Page 33: Deploying Windows Containers on Windows Server 2016

Microsoft

Page 34: Deploying Windows Containers on Windows Server 2016

Windows Linux Subsystem

• Completely unrelated• Maybe not in the future…

Page 35: Deploying Windows Containers on Windows Server 2016

What is a Windows Docker Image?

Page 36: Deploying Windows Containers on Windows Server 2016

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 37: Deploying Windows Containers on Windows Server 2016

PS C:\> docker run -it \ windowsservercore cmd C:\> dir Users Program Files Windows etc

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

Page 38: Deploying Windows Containers on Windows Server 2016

Building Windows based Docker Images

Page 39: Deploying Windows Containers on Windows Server 2016

PS C:\> docker run -it \ --name iisbase \ windowsservercore cmd [iisbase] C:\>

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

Page 40: Deploying Windows Containers on Windows Server 2016

PS C:\> docker run -it \ --name iisbase \ windowsservercore cmd C:\> powershell.exe Install-WindowsFeature web-server C:\> exit

PS C:\> docker commit iisbase windowsservercoreiis 4193c9f34e320c4e2c52ec52550df225b2243927ed21f014fbfff3f29474b090

Page 41: Deploying Windows Containers on Windows Server 2016

Running Windows Container

Page 42: Deploying Windows Containers on Windows Server 2016

PS C:\> docker run -it \ --name iisdemo -p 80:80 \ windowsservercoreiis cmd

Page 43: Deploying Windows Containers on Windows Server 2016

docker commit is an anti-pattern

Use a Dockerfile

Page 44: Deploying Windows Containers on Windows Server 2016

C:\docker-iis> type Dockerfile

FROM windowsservercore:10.0.10586RUN dism /online \ /enable-feature \ /all \ /featurename:iis-webserver \ /NoRestart

Page 45: Deploying Windows Containers on Windows Server 2016

C:\>docker build –t iis:10 c:\docker-iis

C:\> docker imagesREPOSITORY TAG IMAGE ID CREATEDiis 10 as4w9c928829 9 seconds ago windowsservercore 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 46: Deploying Windows Containers on Windows Server 2016

C:\SourceCode\App> type Dockerfile

RUN echo "Hello World - Dockerfile" > c:\inetpub\wwwroot\index.html

Page 47: Deploying Windows Containers on Windows Server 2016

C:\SourceCode> docker build –t app .

PS C:\> docker imagesREPOSITORY TAG IMAGE ID CREATEDapp latest k23jjin423d 1 minutes ago iis 10 as4w9c928829 9 minutes ago windowsservercore 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 48: Deploying Windows Containers on Windows Server 2016

PS C:\> docker run –name -it -p 80:80 app cmd

Page 49: Deploying Windows Containers on Windows Server 2016

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

Page 50: Deploying Windows Containers on Windows Server 2016

Building Windows Nano image?

• Wait until TP5

> docker run --name iisnanobase -it -v c:\share:c:\iisinstall --isolation=hyperv nanoserver cmd

> docker commit iisnanobase nanoserveriis

Page 51: Deploying Windows Containers on Windows Server 2016

ImmutableDisposable Container Pattern

Page 52: Deploying Windows Containers on Windows Server 2016

Simplification of deployments via automation

Page 53: Deploying Windows Containers on Windows Server 2016

Jenkins• Builds Docker

ImageTesting QA Production

Build Lifecycle

Page 54: Deploying Windows Containers on Windows Server 2016

Powershell API

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

Page 55: Deploying Windows Containers on Windows Server 2016

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

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

Page 56: Deploying Windows Containers on Windows Server 2016

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

-v /opt/docker/elasticsearch:/data

-v /opt/docker/mysql:/var/lib/mysql

-v /docker/scrapbook/uploads:/app/public/uploads

-v $(PWD):/host

-v /var/log/syslog:/var/log/syslog

Page 57: Deploying Windows Containers on Windows Server 2016

Users and Domains

• Local user accounts may be created and used for running Windows services and applications in containers

• Containers cannot join Active Directory domains, and cannot run services or applications as domain users, service accounts, or machine accounts.

• "Microsoft are actively looking at solutions to support these types of scenarios."

Page 58: Deploying Windows Containers on Windows Server 2016

Difference to Docker on Linux

Page 59: Deploying Windows Containers on Windows Server 2016

Docker Images will behave as expected

• Linux Manifest• Windows Manifest• ARM Manifest• Future IoT thing Manifest

• docker pull redis– Image pulled depends on Docker Engine

Page 60: Deploying Windows Containers on Windows Server 2016

What’s happening under the covers?

Page 61: Deploying Windows Containers on Windows Server 2016

Linux / Windows

• Linux has cgroups and namespaces– cgroups – How much access/resources do I have?– namespaces – What can I see?

• Windows wanted this in the Kernel• Prototype was called Drawbridge• Server 2016 Kernel brings in the new

cgroups/namespaces• Microsoft reached out to Docker to partner

Page 62: Deploying Windows Containers on Windows Server 2016
Page 63: Deploying Windows Containers on Windows Server 2016

Security?

Page 64: Deploying Windows Containers on Windows Server 2016

What about developers?

Page 65: Deploying Windows Containers on Windows Server 2016
Page 66: Deploying Windows Containers on Windows Server 2016

Running Containers in Production

Page 67: Deploying Windows Containers on Windows Server 2016
Page 68: Deploying Windows Containers on Windows Server 2016
Page 69: Deploying Windows Containers on Windows Server 2016

Bin Packing Pattern

Page 70: Deploying Windows Containers on Windows Server 2016

Mesosphere DC/OS

Powering Azure Container Service

Page 71: Deploying Windows Containers on Windows Server 2016

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)

Page 72: Deploying Windows Containers on Windows Server 2016

The Future?

Page 73: Deploying Windows Containers on Windows Server 2016
Page 74: Deploying Windows Containers on Windows Server 2016

SQL Server as a Container

Page 75: Deploying Windows Containers on Windows Server 2016

Visual Studio as a Container?

Page 76: Deploying Windows Containers on Windows Server 2016

Everything as a Container

Page 77: Deploying Windows Containers on Windows Server 2016

Deploy Anywhere

Page 79: Deploying Windows Containers on Windows Server 2016

www.katacoda.com

Page 80: Deploying Windows Containers on Windows Server 2016
Page 81: Deploying Windows Containers on Windows Server 2016

Summary

• Docker and Containers have changed how Linux processes are managed

• Real container support coming to Windows Kernel

• Automation will be easier

• Better ROI and cluster management

Page 82: Deploying Windows Containers on Windows Server 2016

Thank you!

@[email protected]

www.Katacoda.com

Questions / Beer?