Skip to main content

Integration & IT Modernization

Running Docker in Windows For a Lightweight Solution

“Operating system” (or OS) is a phrase that everyone in IT knows. The first thing that clicks in most of our minds when we think of an OS is Windows, but many OSes available in the market give you a similar experience to Windows. Most developers, coders, or system administrators use services like Hypervisors or Virtual Box because of their ability to run multiple OSes inside a single host OS. The issue with these solutions is that they are very bulky in size and consume more space thereby utilizing a heavy amount of resources to run. This prompts the question about whether there’s an alternative – does something similar exist in a more lightweight way?

What are Docker and containers?

Docker is just like an OS platform – without a whole OS. Instead, Docker uses OS-level virtualization to carry software in packages called containers. Containers are isolated from each other and have their own libraries, packages, and software, and communicate with their defined channels or mediums.

There are many tutorials available online that will provide you with basic to advanced knowledge of Docker and how it works on Linux. This article, however, will provide you with an understanding of Docker in Windows and how effective it is when compared to industry level use for servers.

Features of Docker/containers

Containers are software in packages with their own OS-level architecture. In housing their own libraries of OSes, containers are flexible, standalone, lightweight, secure, and includes everything needed to run your apps.

Docker in Windows can be downloaded from the Docker website and is very easy to install compared to Linux because it’s not a command base. After installation, Docker will only run Linux-mode virtualization with its own MobyLinuxVM by default. It also uses own set of configurations and build up by default, but you can change it. By going to Docker → Setting → Advanced, you can scale the VM as per your use.

To work in Docker with Windows, you need to switch Docker to Windows virtualization, which you can do on right-clicking on Docker bar inside the notification tray and simply click on Switch to Windows Containers. To download software in packages, you can use the Kitematic tool in Docker. This needs to be installed as per the instructions mentioned on the website. Alternatively, you can simply download from Docker store.

There are more than 19,000 software packages available for Windows and more than 200,000 packages for Linux, where you can download Windows IIS servers to MSSQL servers for hosting purposes. The images there are bulkier than Linux images but they are lightweight compared to the original Windows exe images.

For hosting in Windows with Windows IIS inside a Docker platform, we need to download Windows IIS image. We can do this with the following command run in the command prompt:

>docker pull mcr.microsoft.com/windows/servercore/iis

You can check on if the Docker image is downloaded or not with the command:

> docker image ls

After testing, you can run the image simply by using the command below:

>docker run -d -p 8000:80 --name perficient-example iis-site

To verify if the default site is loading or not, you can browse the website in your browser. You require the IP address to do this as the Windows IIS website currently can’t be loaded with localhost input because of WinNAT exception. Docker documentation assures that this will be fixed in the future.

To extract the IP address from the running container, you can run the following command:

>docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" perficient-example

Note: The name should be the same as in the Docker run command. If it’s not, it will throw you an incorrect value or exception error.

To simply browse the site, use the below URL in your browser with the mapped port as in the run command.

>curl -I http://192.168.0.5:8000

We can also run an existing .Net MVC application in Docker containers. To do this, you just need to follow the instructions as provided in this link from Microsoft.

We can also run SQL Server with a combination of IIS. To do this, we just need to pull the image again from the Docker store with the below command.

>docker pull microsoft/mssql-server-windows-expres

And then, to run the SQL server, run the below command:

>docker run -d -p 1433:1433 -e sa_password=<sa_password> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-express

This will set up a SQL server with a password. You can then log in to SQL server by running SSMS in Windows with the SQL server container IP, username, and password that have been assigned.

“If you really want to master Docker, make sure to find a project or a course as practice makes a man perfect.”

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.