Docker is an exciting new feature included in the latest versions of the Windows Server operating systems. Yes, Docker containers are not just for Linux. In 15 minutes, you can create your first Docker container in Windows.
A production version of Docker in Windows is not available. For that reason, there is a lot of misinformation online – especially getting started. Now you will have clear and concise steps.
This is written for everyone – not just developers.
The starting point is a Windows 2016 Server TP 5 virtual machine available with Microsoft Azure. Yes, you need to have a Microsoft Account for this exercise.
The goal of this exercise is to create the most basic of Docker containers in Windows. It won’t do much but guaranteed to work. During the process, you will learn a lot.
Here is the starting line. Go to the Microsoft Azure Portal. Log in.
Stopwatch ready? Ready. Set. Go.
Select the +New button at the top-left corner. Then search for the word “Container”. From the resulting list, locate and select Windows Server 2016 with Container Tech Preview 5. In the right pane, press the Create button.
You can now create a VM in 4 steps. Complete the Basic information in Step 1. See below and substitute your personal information, such as user name and password.
The next step is Choose a size. Select option 2. Notice the price – over $200 per month! Remember to kill the VM after this exercise to avoid most of this cost. The next step is Storage. Accept defaults. The final step is Summary. Review and then select the OK button. Azure will now create the VM. This will take 5 minutes. 1/3 of our 15 minutes!
Choose the Virtual Machines menu item from the left pane. Select the just created VM from the list. Choose Connect to run the VM within a Remote Desktop. You will be prompted to save a RDP file. Save and open the file in Remote Desktop Connection (mstsc). From the security window, log into the virtual machine. Use the credential provided when setting up the VM.
Once the VM has started, open a command window. Enter Docker version command from the command prompt.
Version information on Docker will be displayed. Most important, it verifies Docker is working!
Now enter the Docker images command. It lists your images includes WindowsServerCore, which is an operating system image. Let us create a container from this image. If terms, such as image or container are foreign, there are many introductions to Docker online.
Create a sub-directory called Pinger – “md Pinger”. A docker batch file is called Dockerfile (no extension), where you list Docker commands to execute. In the Pinger directory, create the DockerFile text file “notepad Dockerfile.”. Enter the following information into the file.
CMD ping 184.108.40.206
Close and save the file. Build the Dockerfile and create an image with this command. Note:the Docker Build command implicitly uses the Dockerfile file.
docker build -t app:1 c:\pinger
List the available images – docker images. You should see your new image “app”.
Create and run a container from this image. Enter this command
docker run –rm app:1
You should see pinging J. Congratulations on creating and running your first container in 15 minutes!
To learn more about Docker contact Learn It. Your home of everything Docker.
Dalit Lewis – Dalit.Lewis@learnit.com
Matt Murawski – Matt.Murawski@learnit.com
Note. Remember to delete the VM in Azure after this exercise to avoid unnecessary costs.