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:
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:
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.