4b449000-d256-49f9-95f1-9844044a66a3.png
jochen.png
Jochen Zehnder

How to get started with IIS on Docker

In one of our customer projects, we have a mixed Swarm Cluster with Linux and Windows nodes. On the Windows nodes, we run a bunch of IIS containers that run several web applications. In this blog post, I want to showcase you how easy it is to deploy a Website on IIS in a Docker Container.

The Internet Information Services (IIS) is a web server for Windows Server. You can find more information about it on the official Web Site. Microsoft already provides a large list of Docker Images for IIS. You can find more information on Docker Hub and the Dockerfiles for the images in the GitHub Repo.

The Code

A web server allows you to access files from a folder via HTTP requests. For IIS the default folder is C:\inetpub\wwwroot. This means, that you need to add the content of your website to this folder. The screenshot below shows an example folder structure. There you can see that all the content of the website is in the wwwroot-folder.

Besides the content of your website, all you need is a Dockerfile with only two lines of code:

FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019

ADD wwwroot /inetpub/wwwroot/

With the Dockerfile in place, open this folder in PowerShell. To build the container image, execute the following command:

docker build -t iis-website .

After building the image, you can run the container:

docker run -p 80:80 iis-website

Now you can access the website in your favorite browser with the URL http://localhost. Be aware, that it can take several seconds for Windows Containers to start. This means you have to wait a bit until the website appears in your browser.

You can extend this approach, to also add all the required configurations to the Dockerfile. This allows you to track all the changes in your version control system. This enables you to add the building, testing, and deployment to your CI/CD pipeline.

Summary

In this post, I showed how easy it is to run a website on IIS in a Docker container. By specifying everything in code you can add the configurations and all the needed files to your version control system. This enables you to integrate it into a CI/CD pipeline, one piece of the DevOps puzzle.

In the meantime, I have recorded a video that also explains the needed steps.

As a bonus, it is also available in German.

More Information

I didn't cover how to get started with Docker on Windows in this post. You can find more information about that in the official documentation:

For more information about IIS on Docker, you can head over to the following links:

Find out more about 56K.Cloud

We love Cloud, IoT, Containers, DevOps, and Infrastructure as Code. If you are interested in chatting connect with us on Twitter or drop us an email: info@56K.Cloud. We hope you found this article helpful. If there is anything you would like to contribute or you have questions, please let us know!

Jochen Zehnder

Jochen Zehnder

Cloud-Native Consultant and Partner

"Cloud-Native Consultant and Partner"