Sunday, October 23, 2016

Run Windows Nano Server As Docker Container

Setting Context 


Microsoft recently came out with their version of docker support with the release of windows server 2016 and windows nano server. Although Microsoft have to go long way to make docker support seamless and as stable as in other linux and osx platforms, but a start is always welcomed in Net developers fraternity. Huge number of developers are evaluating this new buzz in town.
I work on open source technology stack like angular, react, node etc. and adopted docker in linux early this year. I must say its really cool to see this finally in Microsoft tech. stack and its too early to say, but its not ready for production. I will limit using these for research or perhaps small development environment.

Installation 


I am running window server 2016 standard edition. One can download the vhd with 180 days trial but be aware they can't be upgraded to standard edition after expiry of 180 days, at-least this was the case while writing. So lets jump on some action. So take you VHD and use virtual box or any tool of your choice to mount it as VM. In my case I am using Parallels.

First Things First [Very Important :) ]


Once you are done you need to go through basic steps to enable docker. Oh! wait the most important thing you will ever learn with windows, first update it. If you don't get the latest updated definition, you might get several issues, at-least I got several weird exceptions but just by updating all the issues just disappeared.

Run Docker in Windows 2016 server 


Run this commands in PowerShell with elevated privileges

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer -Force

Once you computer restarts, run docker version and you should be able to see output something like this




This means you docker service is running. You can check it by running -  Service Docker. This should show the service should be in running state.

Get Nano Server 


Since our goal is to run Nano server. Lets fetch the nano server from docker hub. Use PowerShell running in elevated permission to run

  • docker pull microsoft/nanoserver 

This should fetch the nanoserver images and now you should be able to see it in by running 
  • docker images

Now we have got the image in local, so run it by 

  • docker run -it [ImageID from above command]
It will open up a new prompt which is essentially a command prompt in nano server. Voila you are able to run nano server successfully.


You can open up PowerShell by typing PowerShell and hit enter. Since this is just a bare window platform, you need to install everything as per your need. Next blog I will try to demonstrate how you can run IIS inside the nano server. Till then enjoy Dockering......!

No comments:

Post a Comment