Wednesday, June 20, 2018

Don’t be Scared of Dockers

Let me introduce myself, I am Harish and have been a Microsoft user for very long. I love the technology, but that didn’t stop me from exploring other open source platforms. If you look at the market trends the new buzz words are cloud, micro services and every person is talking about Agile. Dockers is one of the core components for micro services platform, and can help on Agile methodology as well. This blog is about my journey learning and experimenting on Dockers on Microsoft platform. The issues I faced and how I was able to successfully install Dockers and some GUI management tools for the same. I will try and explain my thought process and mistakes I made during the decision process.

For someone who is not so well versed on Dockers or containerization it can be scary at first. My suggestion would be take baby steps, slow and steady.

For people who have a Linux background it would be easy to pick up the containerization technology, Microsoft users need not feel bad. Microsoft has done a fine job on windows 2016 and they are working with containerization platform companies to help us conquer the new beast ‘Containers’.

I am not going to explain what is Docker here, there are lot of sites which talk about it and what are the benefits of Dockers and containerization. Most of the processes I follow here would refer back to the Docker documentation and Microsoft documentation. The documents are excellent, I would suggest everyone to go through the documents atleast once, and there is a lot of knowledge available in the following links.

https://docs.docker.com/docker-for-windows/

https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon

Let’s take one step at a time and create our testbed.

Step 1: Install Hyper-V on your windows laptop

To start the installation we need to enable Hyper-v on our Windows 10 laptop.

You can follow the detailed instructions from

https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v

I enabled Hyper-V using the settings from control panel. Nothing specific on why I did not use the PowerShell. I just feel comfortable using the GUI.

clip_image001

Step 2: Installation of Windows 2016

As I call it Docker comes in two flavors for Windows OS, Docker for Windows (for PC’s) and Docker on Windows 2016 (for servers or Production). There are lot of architectural differences which we will be discussing at a later point of time. Just as a highlight Docker Engine on Docker for Windows is based on Linux kernel and Docker on Windows 2016 is based on Windows kernel and HAL. There are few commands like docker-machine which will not work on Dockers on Windows 2016.

We can go on and on discussing about Dockers but let’s come back to our project scope where I want to test Dockers on Windows 2016 with an GUI monitoring tool. For that we would need Windows 2016. We will use the trail edition of Windows for this testing. You can download a absolutely free trial edition of windows 2016 using the below link

https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2016

Ensure you select the ISO option to download the file. The download would be approximately 8GB in size.

clip_image003

a) To start the installation open the Hyper-v manager from Control panel -> Administrative Tools -> Hyper-v Manager

clip_image005

b) Click on New under the Actions Pane and select Virtual Machine

clip_image006

c) Enter the name for Virtual server, I have named it VMWD2016 just to indicate it is a Virtual Machine, Windows, running Dockers and edition of windows 2016, you may name it as per your convenience. Set the location where you want to store the VM, I have left it as default

clip_image008

d) In Generation I left it as Generation 1, and for memory we set it as 4096 (4GB)

e) For now leave the network to be not connected. We will create a switch and join this VM to new switch later once we go and create Docker Swarm.

f) Create a Virtual Hard Disk for 100GB to be safe.

clip_image010

g) In the installation options select “ Install an operating system from a bootable CD/DVD-ROM and then select Image browse to the path where you downloaded the Windows iso file

clip_image012

h) Review the summary and click finish to start the VM to start configuring.

i) Newly created VM will be listed in Virtual Machines pane.

clip_image014

j) Next right click on the newly created VM and select settings and in the newly opened setting click on Checkpoints,

As this is a trail setup you can disable the checkpoints (uncheck). Disabling checkpoint is optional, I feel it is annoying to leave it enabled on test machines.

clip_image016

k) Next click on the newly created Virtual machine and click start

clip_image017

l) You will notice the VM will start consuming the processor, memory etc. Next right click again and click connect.

clip_image018

m) Once you are connected select the language and then click next

n) Click install on the screen

o) On windows setup select the “Windows Server 2016 Standard Evaluation (Desktop Experience)”. As this setup will install the desktop and the server core only. Windows has lot of other options now a days, the nano, core and desktop experience. For the newbies or old generation windows users the desktop will be of help as it makes it really easy to navigate in windows. You can use the core edition also for setting Dockers, just for ease I am selecting to install the desktop.

image

p) Click next and follow the setup. Just perform a simple default installation.

Step 3: Installation of Dockers:

Installation on Dockers can be very straight forward if you can follow the directions given on the Docker Docs:  https://docs.docker.com/install/windows/docker-ee/#use-a-script-to-install-docker-ee

I would suggest,

a) First go to the below link to find the stable version and download it direct on to the system which is connected to internet first

https://download.docker.com/win/static/stable/

b) Logon to the newly created Virtual server and  Launch Add Roles and Features Windows from Server manger.

Go to Features and Enable the Containers Feature

image

c) Copy the downloaded docker file over to the Virtual server which we created in our above step, Rename the file as Docker.zip.

image_thumb

d) Open a Windows PowerShell on the newly installed virtual server with Administrative permissions. Change the path to the location where the docker.zip is located and run the below command:

  Expand-Archive Docker.zip –DestinationPath $Env:ProgramFiles

image_thumb[2]

image_thumb[3]

Lets disect the above command, Expand-Archive means to expand a zip file which will take 2 paths the source and destination path. In destination path we are asking PowerShell to go to environment variables and take the path for program files.

So once the above command is run, it will create a Folder called Docker in Program Files and extract the files there.

Lets see if it worked, the folder will have 2 files, docker and dockerd.

image_thumb[1]

e) Add a new windows Environment path using the below command

   $Env:Path += “$Env:ProgramFiles\Docker”

image_thumb[4]

Lets open the the Environmental variables and check if the necessary setting is already added. For that lets type sysdm.cpl in command prompt, it will open up system properties for us. To learn how to launch control panel items from command prompt you can refer to the below link,

https://support.microsoft.com/en-us/help/192806/how-to-run-control-panel-tools-by-typing-a-command

image_thumb[5]

image_thumb[6]

Click on Environment Variables

image_thumb[7]

Select the System variables path, then click on edit

image_thumb[8]

Verify the C:\ProgramFiles\Docker is listed.

f) Next we need to register docker as a service, type the below command

dockerd –register -service

image_thumb[9]

g) Restart the server

h) Open the services and check if docker listed. Start the service

image_thumb[10]

Congrates !! Docker is installed on windows server 2016.

Let’s verify if docker is working

Open powershell and lets run the below command

docker ps

image_thumb[11]

Docker ps will list all the docker containers running. Usually as it is newly installed you will not see any containers running unlike in the screen shot(I was testing the portainer container, details of which will be explained in another blog. You can also install the docker using the below commands

Install-Module DockerMsftProvider -Force
Install-Package Docker -ProviderName DockerMsftProvider –Force

Rather going through the manual process of downloading the file and registering the same,

I wanted to keep the installation/ testbed scenario as close to Production experience as possible. And also wanted to learn the nitty gritty of installation process so it can be helpful in future for troubleshooting. Also in many a case our production environments may not be open to internet. If you want you can just enable container as discussed in step b of docker installation and then run the above two commands if your server is connected to the internet,

To conclude this blog, we enabled hyper-v, installed the trail edition Windows 2016 and installed Docker. Next blog we will see how to set a docker cluster and continue from there.

No comments:

Post a Comment