Home
%3CLINGO-SUB%20id%3D%22lingo-sub-990785%22%20slang%3D%22en-US%22%3EModernize%20your%20IT%20environment%20and%20applications%20with%20Windows%20Containers%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-990785%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20Ignite%20week%20and%20part%20of%20the%20team%20is%20in%20Orlando%20talking%20to%20customers%20and%20delivering%20sessions.%20It's%20amazing%20to%20see%20the%20enthusiasm%20on%20Windows%20Containers%20with%20more%20and%20more%20people%20stopping%20by%20to%20ask%20how%20they%20can%20get%20started%20and%20how%20they%20can%20containerize%20their%20first%20application.%3C%2FP%3E%0A%3CP%3EThat's%20why%20Craig%20and%20I%20are%20doing%20a%20session%20today%20called%20%22%3CA%20href%3D%22https%3A%2F%2Fmyignite.techcommunity.microsoft.com%2Fsessions%2F82953%3Fsource%3Dsessions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EModernize%20your%20IT%20environment%20and%20applications%20with%20Windows%20Containers%3C%2FA%3E%22.%20The%20idea%20of%20this%20blog%20post%20is%20to%20server%20as%20a%20reference%20blog%20for%20that%20session%2C%20with%20all%20the%20instructions%20for%20the%20demos%20we%20presented%20today.%3C%2FP%3E%0A%3CP%3EDuring%20the%20session%20we%20cover%20how%20you%20can%20containerize%20an%20ASP.Net%203.5%20web%20application%20running%20on%20Windows%20Server%202008%20R2%20with%20Windows%20containers%20on%20Windows%20Server%202019.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3ETest%20proofing%20your%20application%20on%20Windows%20Server%202019%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EBefore%20we%20get%20into%20the%20containers%20portion%2C%20it's%20important%20to%20understand%20how%20your%20application%20behaves%2C%20what%20are%20its%20components%2C%20and%20how%20you%20can%20validate%20that%20the%20application%20actually%20runs%20on%20Windows%20Server%202019%20-%20or%20at%20least%20Windows%20Server%202016%20for%20that%20matter%20-%20so%20you%20know%20it%20will%20work%20in%20a%20container.%3C%2FP%3E%0A%3CP%3EIn%20order%20to%20do%20that%2C%20you'll%20have%20to%20check%20how%20do%20you%20deploy%20that%20application.%20For%20our%20case%2C%20since%20this%20is%20a%20web%20application%20running%20on%20IIS%2C%20you%20have%20a%20few%20options%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIf%20you%20have%20access%20to%20the%20source%20code%2C%20you%20should%20probably%20work%20with%20the%20dev%20team%20to%20containerize%20the%20application%20directly%20from%20Visual%20Studio.%20Visual%20Studio%20has%20all%20the%20tooling%20embedded%20to%20create%20a%20container%20image%20with%20your%20application%20on%20it.%3C%2FLI%3E%0A%3CLI%3EIf%20you%20have%20a%20package%20with%20your%20application%2C%20you%20need%20the%20instructions%20on%20how%20to%20deploy%20this.%20Traditionally%2C%20developers%20will%20provide%20minimal%20instructions%20on%20how%20to%20deploy%20the%20application%20and%20you%20can%20leverage%20that.%3C%2FLI%3E%0A%3CLI%3EIf%20the%20application%20is%20already%20deployed%2C%20you%20need%20a%20way%20to%20extract%20the%20application%20from%20the%20current%20server.%20For%20web%20applications%20on%20IIS%20there%20are%2C%20thankfully%2C%20a%20couple%20options%20here.%20You%20could%20simply%20export%20the%20applications%20using%20native%20IIS%20commands%20from%20command%20prompt.%20Another%20option%20is%20to%20use%20Web%20Deploy%20to%20export%20the%20application%20into%20a%20Zip%20file%20that%20can%20be%20used%20to%20import%20the%20application%20on%20the%20other%20side.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EOnce%20you%20have%20your%20strategy%20to%20get%20the%20application%20from%20the%20current%20server%20to%20the%20new%20Windows%20Server%202016%20or%202019%2C%20you%20can%20deploy%20the%20application%20and%20validate%20it%20runs%20fine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EContainerizing%20your%20application%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EThe%20process%20to%20containerize%20the%20application%20is%20a%20bit%20different%20than%20most%20admins%20are%20used%20to%20with%20VMs.%20With%20VMs%20you%20deploy%20an%20OS%2C%20than%20the%20app%20dependencies%2C%20than%20the%20app%2C%20and%20finally%20you%20configure%20the%20app.%20Often%20times%2C%20all%20manually.%20After%20all%20that%2C%20you%20generalize%20the%20image%20with%20Sysprep%20and%20store%20the%20VHD%20file%20in%20a%20place%20that%20consumers%20of%20this%20app%20can%20deploy%20a%20new%20VM.%3C%2FP%3E%0A%3CP%3EWith%20containers%2C%20you%20actually%20declare%20how%20your%20application%20will%20be%20composed%20in%20a%20Docker%20file%20(which%20is%20just%20a%20text%20file%20called%20dockerfile%20-%20no%20extension%20-%20in%20the%20same%20folder%20you%20have%20your%20application.%3C%2FP%3E%0A%3CP%3EThe%20Docker%20file%20provides%20the%20instructions%20for%20the%20command%20%22docker%20build%22%20to%20build%20your%20application%20and%20store%20it%20in%20a%20container.%3C%2FP%3E%0A%3CP%3EHere's%20the%20example%20of%20the%20docker%20file%20Craig%20and%20I%20used%20in%20our%20session%20today%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EFROM%20mcr.microsoft.com%2Fwindows%2Fservercore%2Fiis%3Awindowsservercore-ltsc2019%0AWORKDIR%20%2FViniBeer%0ACOPY%20.%20.%0ARUN%20PowerShell%20Install-WindowsFeature%20NET-Framework-45-ASPNET%3B%20%5C%0A%20Install-WindowsFeature%20Web-Asp-Net45%0ARUN%20PowerShell%20Import-Module%20WebAdministration%3B%20%5C%0A%20New-WebApplication%20%22ViniBeer%22%20-Site%20'Default%20Web%20Site'%20-ApplicationPool%20%22DefaultAppPool%22%20-PhysicalPath%20%22C%3A%5CViniBeer%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EFrom%20top%20to%20bottom%2C%20here's%20what%20you%20should%20know%20about%20the%20above%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EFROM%3A%20This%20is%20where%20you%20start%20your%20application%20from.%20There%20are%20multiple%20container%20images%20available%20in%20the%20%3CA%20href%3D%22http%3A%2F%2Fhub.docker.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDocker%20Hub%3C%2FA%3E%2C%20so%20instead%20of%20deploying%20Windows%20components%2C%20you%20can%20most%20probably%20find%20an%20image%20that%20already%20has%20what%20you%20need%20to%20deploy%20your%20app.%20In%20this%20case%2C%20we're%20starting%20with%20the%20IIS%20container%20image%20that%20has%20IIS%20pre-installed.%3C%2FLI%3E%0A%3CLI%3EWORKDIR%3A%20This%20is%20your%20working%20directory.%20It%20assumes%20the%20context%20of%20the%20C%3A%5C%20drive%2C%20so%20in%20the%20case%20above%20it%20will%20create%20a%20new%20folder%20at%20C%3A%5CViniBeer%20and%20set%20that%20folder%20as%20the%20working%20directory.%20Throughout%20the%20file%2C%20you%20can%20simply%20reference%20this%20folder%20with%20a%20%22.%22.%3C%2FLI%3E%0A%3CLI%3ECOPY%3A%20As%20the%20name%20says%2C%20this%20will%20copy%20content%20into%20the%20container.%20The%20way%20the%20context%20work%20here%20is%20the%20first%20path%20is%20the%20local%20container%20host%20from%20which%20you%20are%20running%20docker%20build.%20The%20second%20path%20is%20the%20path%20inside%20the%20container.%20In%20our%20case%2C%20we're%20copying%20the%20content%20from%20the%20folder%20we're%20running%20docker%20build%20to%20the%20C%3A%5CViniBeer%20working%20directory%20we%20referenced%20earlier.%3C%2FLI%3E%0A%3CLI%3ERUN%3A%20Run%20will%20execute%20commands%20inside%20the%20container%20to%20get%20it%20prepared.%20The%20example%20above%20is%20using%20PowerShell%20and%20then%20the%20commands%20to%20run%20on%20it.%20The%20first%20one%20deploys%20the%20ASP.Net%20IIS%20dependencies%20and%20the%20second%20one%20imports%20the%20IIS%20PowerShell%20module%20to%20then%20install%20the%20web%20application%20-%20just%20like%20you%20would%20do%20in%20a%20regular%20Windows%20Server%20with%20Server%20Core.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20docker%20build%20command%20you%20run%20to%20execute%20all%20this%20is%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Edocker%20build%20-t%20vinibeerimage%20.%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThis%20will%20tag%20the%20image%20as%20%22vinibeerimage%22%20and%20store%20the%20image%20locally.%20Now%20all%20you%20have%20to%20do%20is%20deploy%20new%20containers%20based%20on%20that%20container%20image.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20it%20yourself%20with%20our%20Vini%20Beer%20sample%20app.%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20try%20the%20exact%20same%20demo%20we%20ran%20in%20our%20session%20at%20Microsoft%20Ignite%2C%20you%20can%20use%20the%20Vini%20Beer%20sample%20ASP.Net%203.5%20app%20that%20was%20running%20in%20a%20Windows%20Server%202008%20R2%20machine.%20The%20app%20is%20stored%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fvrapolinario%2FViniBeer%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20repository%3C%2FA%3E%20-%20along%20with%20the%20docker%20file%20above.%3C%2FP%3E%0A%3CP%3EThe%20%3CA%20href%3D%22https%3A%2F%2Fmyignite.techcommunity.microsoft.com%2Fsessions%2F82953%3Fsource%3Dsessions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erecording%20for%20the%20session%3C%2FA%3E%20will%20be%20available%20later%20today.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20hope%20this%20helps%20in%20your%20containerization%20journey!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-990785%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20is%20Ignite%20week%20and%20part%20of%20the%20team%20is%20in%20Orlando%20talking%20to%20customers%20and%20delivering%20sessions.%20It's%20amazing%20to%20see%20the%20enthusiasm%20on%20Windows%20Containers%20with%20more%20and%20more%20people%20stopping%20by%20to%20ask%20how%20they%20can%20get%20started%20and%20how%20they%20can%20containerize%20their%20first%20application.%3C%2FP%3E%0A%3CP%3EThat's%20why%20Craig%20and%20I%20are%20doing%20a%20session%20today%20called%20%22%3CA%20href%3D%22https%3A%2F%2Fmyignite.techcommunity.microsoft.com%2Fsessions%2F82953%3Fsource%3Dsessions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EModernize%20your%20IT%20environment%20and%20applications%20with%20Windows%20Containers%3C%2FA%3E%22.%20The%20idea%20of%20this%20blog%20post%20is%20to%20server%20as%20a%20reference%20blog%20for%20that%20session%2C%20with%20all%20the%20instructions%20for%20the%20demos%20we%20presented%20today.%3C%2FP%3E%0A%3CP%3EDuring%20the%20session%20we%20cover%20how%20you%20can%20containerize%20an%20ASP.Net%203.5%20web%20application%20running%20on%20Windows%20Server%202008%20R2%20with%20Windows%20containers%20on%20Windows%20Server%202019.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

This is Ignite week and part of the team is in Orlando talking to customers and delivering sessions. It's amazing to see the enthusiasm on Windows Containers with more and more people stopping by to ask how they can get started and how they can containerize their first application.

That's why Craig and I are doing a session today called "Modernize your IT environment and applications with Windows Containers". The idea of this blog post is to server as a reference blog for that session, with all the instructions for the demos we presented today.

During the session we cover how you can containerize an ASP.Net 3.5 web application running on Windows Server 2008 R2 with Windows containers on Windows Server 2019.

 

Test proofing your application on Windows Server 2019

Before we get into the containers portion, it's important to understand how your application behaves, what are its components, and how you can validate that the application actually runs on Windows Server 2019 - or at least Windows Server 2016 for that matter - so you know it will work in a container.

In order to do that, you'll have to check how do you deploy that application. For our case, since this is a web application running on IIS, you have a few options:

  • If you have access to the source code, you should probably work with the dev team to containerize the application directly from Visual Studio. Visual Studio has all the tooling embedded to create a container image with your application on it.
  • If you have a package with your application, you need the instructions on how to deploy this. Traditionally, developers will provide minimal instructions on how to deploy the application and you can leverage that.
  • If the application is already deployed, you need a way to extract the application from the current server. For web applications on IIS there are, thankfully, a couple options here. You could simply export the applications using native IIS commands from command prompt. Another option is to use Web Deploy to export the application into a Zip file that can be used to import the application on the other side.

Once you have your strategy to get the application from the current server to the new Windows Server 2016 or 2019, you can deploy the application and validate it runs fine.

 

Containerizing your application

The process to containerize the application is a bit different than most admins are used to with VMs. With VMs you deploy an OS, than the app dependencies, than the app, and finally you configure the app. Often times, all manually. After all that, you generalize the image with Sysprep and store the VHD file in a place that consumers of this app can deploy a new VM.

With containers, you actually declare how your application will be composed in a Docker file (which is just a text file called dockerfile - no extension - in the same folder you have your application.

The Docker file provides the instructions for the command "docker build" to build your application and store it in a container.

Here's the example of the docker file Craig and I used in our session today:

FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019
WORKDIR /ViniBeer
COPY . .
RUN PowerShell Install-WindowsFeature NET-Framework-45-ASPNET; \
	Install-WindowsFeature Web-Asp-Net45
RUN PowerShell Import-Module WebAdministration; \
	New-WebApplication "ViniBeer" -Site 'Default Web Site' -ApplicationPool "DefaultAppPool" -PhysicalPath "C:\ViniBeer"

From top to bottom, here's what you should know about the above:

  • FROM: This is where you start your application from. There are multiple container images available in the Docker Hub, so instead of deploying Windows components, you can most probably find an image that already has what you need to deploy your app. In this case, we're starting with the IIS container image that has IIS pre-installed.
  • WORKDIR: This is your working directory. It assumes the context of the C:\ drive, so in the case above it will create a new folder at C:\ViniBeer and set that folder as the working directory. Throughout the file, you can simply reference this folder with a ".".
  • COPY: As the name says, this will copy content into the container. The way the context work here is the first path is the local container host from which you are running docker build. The second path is the path inside the container. In our case, we're copying the content from the folder we're running docker build to the C:\ViniBeer working directory we referenced earlier.
  • RUN: Run will execute commands inside the container to get it prepared. The example above is using PowerShell and then the commands to run on it. The first one deploys the ASP.Net IIS dependencies and the second one imports the IIS PowerShell module to then install the web application - just like you would do in a regular Windows Server with Server Core.

The docker build command you run to execute all this is:

docker build -t vinibeerimage .

This will tag the image as "vinibeerimage" and store the image locally. Now all you have to do is deploy new containers based on that container image.

 

Try it yourself with our Vini Beer sample app.

If you want to try the exact same demo we ran in our session at Microsoft Ignite, you can use the Vini Beer sample ASP.Net 3.5 app that was running in a Windows Server 2008 R2 machine. The app is stored in this GitHub repository - along with the docker file above.

The recording for the session will be available later today.

 

We hope this helps in your containerization journey!