Docker All The Things - ASP.NET 4.x and Windows Server Containers

44
@nthonyChu #SeattleCodeCamp #DockerAllTheThings Dockerizing ASP.NET 4.x Apps Anthony Chu

Transcript of Docker All The Things - ASP.NET 4.x and Windows Server Containers

Page 1: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Dockerizing ASP.NET 4.x AppsAnthony Chu

Page 2: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Containers

Docker

Windows Server Containers

Dockerizing ASP.NET

Hyper-V Containers, Windows 10

Page 3: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Who's Anthony?

Developer from Vancouver, BC

Experimenting with Docker on Windows

Microsoft MVP - Azure

Page 4: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Typical Development Process

Develop application locally

Deploy to QA environment and test

Deploy to production environment

Page 5: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

The App Deployment ProblemEnvironments must be kept the same

“Works on my machine”

Set up servers to run different types of apps

Conflicts between dependency versions

Long lived servers

Page 6: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Infrastructure as Code

Ephemeral infrastructure

Easier to have consistently configured servers

Code and configuration are separate

Page 7: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Immutable Virtual MachinesCreate VMs as part of build process

VM as a unit of deployment

Devs build the app and configures environment

Slow to start up

Take up lots of resources

Page 8: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Virtual Machines

Infrastructure

Host OS

Virtual Machine

Dependencies

App

Virtual Machine

GuestOS

Dependencies

App

GuestOS

Containers

Infrastructure

Host OS

Container

Dependencies

App

Container

Dependencies

App

Page 9: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

ContainersKernel virtualization, host-level performance

Consistently deployed by ops

No longer a need for specially configured servers

Can be deployed on same server or separate

Devs responsible for building app and environment

Page 10: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Containers

By Patrick Denker from Athens, GA (DSC04878) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons

Page 11: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker and containers

Containers support existed in Linux for a while

Docker made them accessible

Common tooling

Page 12: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker ToolingDocker Client

Docker Engine

Docker Machine

Docker Compose

Docker Swarm

Docker Registry

Page 13: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker and Linux Containers

Linux

Linux Docker Engine

REST API

Docker Client Docker Compose Docker Swarm more…

Page 14: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker ImagesContainer “templates”

Images can be local

Share with others using a registry (Docker Hub)

Created manually or using a Dockerfile

Can be tagged

Page 15: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Operating System ImagesBasic building block

“Clean install” of an OS

Examples • ubuntu • debian • windowsservercore

Page 16: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Dockerfile

• Base image • Install dependencies • Build application • Specify entry point

Page 17: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Dockerfile

FROM ubuntu:14.04

RUN apt-get update && apt-get install -y ruby ruby-dev

RUN gem install sinatra

Page 18: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker Build

$ docker build -t anthonychu/ruby:0.1.0 .

$ docker push anthonychu/ruby:0.1.0

Page 19: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Dockerfile

FROM anthonychu/ruby:0.1.0

ADD . /src

WORKDIR /src

ENTRYPOINT [“ruby”, “foo.rb"]

Page 20: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker Build

$ docker build -t anthonychu/foo .

$ docker run anthonychu/foo

Page 21: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Containers

Can only see its own files and processes

Can set limits on resources used by a container

Page 22: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Continuous Delivery PipelineDocker Hub

Dev QA Productionanthonychu/my-app:1.0

Page 23: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

That’s Linux, but what about…

ASP.NET WebForms?

MVC, Web API, SignalR?

Dependencies that require full .NET Framework?

Don’t want to port to .NET Core?

Page 24: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Windows Server Containers!

Page 25: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Windows Server 2016

Current version is Technical Preview 5

Comes in 2 flavors • Windows Server • Nano Server

Native support for containers

Page 26: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Not Docker for Windows!

Page 27: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker for Windows

Windows

Boot2Docker (Linux) on Hyper-V

Docker EngineDocker Client

Page 28: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker and Windows Server Containers

Windows

Windows Docker Engine

REST API

Docker Client Docker Compose Docker Swarm more…

Page 29: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Demo

Page 30: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Demo

Windows Server 2016 and containers setup

Docker basics

Running a container

Page 31: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

ASP.NET in containersLinux Windows Nano Server

ASP.NET Core (.NET Core) ✔ ✔ ✔

ASP.NET Core (Full Framework) Mono ✔

Web API, SignalR (OWIN Self-host) ✔

WebForms, MVC 5 (IIS) ✔

Page 32: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Demo

Page 33: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Demo

ASP.NET Web API OWIN self host

microsoft/iis image

ASP.NET WebForms in IIS

Page 34: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

So… What’s the point of all this?

Page 35: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Docker all the things

Manage and deploy everything with Docker

Run multiple .NET versions on same machine

No more installing dependencies on servers

Page 36: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Monolith to Microservices

Dockerize monolith

Spin off features into microservices in containers

Repeat until monolith is obsolete

Strangler Application Pattern • http://www.martinfowler.com/bliki/StranglerApplication.html

Page 37: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Mixed Linux/Windows Clusters

Windows Container

Linux Container

Page 38: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Hyper-V Containers Windows 10

Page 39: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Windows Server Containers

Infrastructure

Windows Server 2016

Container

Dependencies

App

Container

Dependencies

App

Utility VM

Hyper-V Containers

Infrastructure

Windows Server 2016 / Windows 10

Container

Dependencies

App

Utility VM

Container

Dependencies

App

Page 40: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Hyper-V Containers

“Utility VM” - Only purpose is to run containers

Fast startup

Currently only Nano Server containers

Page 41: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Hyper-V Containers

Same images as Windows Server Containers

Runtime option

$ docker run --isolation=hyperv my-image

Page 42: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Containers on Windows 10

Windows 10 Anniversary Update

Support for Hyper-V containers only

Instructions at aka.ms/containers

Page 43: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Summary

Docker and containers are a big deal

Dockerize all ASP.NET applications

Windows Server containers coming soon

Manage Linux/Windows containers with same tools

Page 44: Docker All The Things - ASP.NET 4.x and Windows Server Containers

@nthonyChu#SeattleCodeCamp #DockerAllTheThings

Next StepsTry Windows Server 2016

Azure Container Services Windows Private Preview

http://aka.ms/containers

http://anthonychu.ca

@nthonyChu