docker all the things - asp.net 4.x and windows server containers
Post on 25-Jan-2017
331 Views
Preview:
TRANSCRIPT
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Dockerizing ASP.NET 4.x AppsAnthony Chu
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Containers
Docker
Windows Server Containers
Dockerizing ASP.NET
Hyper-V Containers, Windows 10
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Who's Anthony?
Developer from Vancouver, BC
Experimenting with Docker on Windows
Microsoft MVP - Azure
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Typical Development Process
Develop application locally
Deploy to QA environment and test
Deploy to production environment
@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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Infrastructure as Code
Ephemeral infrastructure
Easier to have consistently configured servers
Code and configuration are separate
@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
@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
@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
@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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker and containers
Containers support existed in Linux for a while
Docker made them accessible
Common tooling
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker ToolingDocker Client
Docker Engine
Docker Machine
Docker Compose
Docker Swarm
Docker Registry
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker and Linux Containers
Linux
Linux Docker Engine
REST API
Docker Client Docker Compose Docker Swarm more…
@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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Operating System ImagesBasic building block
“Clean install” of an OS
Examples • ubuntu • debian • windowsservercore
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Dockerfile
• Base image • Install dependencies • Build application • Specify entry point
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y ruby ruby-dev
RUN gem install sinatra
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker Build
$ docker build -t anthonychu/ruby:0.1.0 .
$ docker push anthonychu/ruby:0.1.0
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Dockerfile
FROM anthonychu/ruby:0.1.0
ADD . /src
WORKDIR /src
ENTRYPOINT [“ruby”, “foo.rb"]
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker Build
$ docker build -t anthonychu/foo .
$ docker run anthonychu/foo
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Containers
Can only see its own files and processes
Can set limits on resources used by a container
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Continuous Delivery PipelineDocker Hub
Dev QA Productionanthonychu/my-app:1.0
@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?
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Not Docker for Windows!
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker for Windows
Windows
Boot2Docker (Linux) on Hyper-V
Docker EngineDocker Client
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Docker and Windows Server Containers
Windows
Windows Docker Engine
REST API
Docker Client Docker Compose Docker Swarm more…
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Demo
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Demo
Windows Server 2016 and containers setup
Docker basics
Running a container
@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) ✔
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Demo
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Demo
ASP.NET Web API OWIN self host
microsoft/iis image
ASP.NET WebForms in IIS
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
So… What’s the point of all this?
@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
@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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Mixed Linux/Windows Clusters
Windows Container
Linux Container
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Hyper-V Containers Windows 10
@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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Hyper-V Containers
“Utility VM” - Only purpose is to run containers
Fast startup
Currently only Nano Server containers
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Hyper-V Containers
Same images as Windows Server Containers
Runtime option
$ docker run --isolation=hyperv my-image
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Containers on Windows 10
Windows 10 Anniversary Update
Support for Hyper-V containers only
Instructions at aka.ms/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
@nthonyChu#SeattleCodeCamp #DockerAllTheThings
Next StepsTry Windows Server 2016
Azure Container Services Windows Private Preview
http://aka.ms/containers
http://anthonychu.ca
@nthonyChu
top related