Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Lab: Implementing and configuring virtualization in Windows Server

Scenario

Contoso is a global engineering and manufacturing company with its head office in Seattle, USA. An IT office and data center are in Seattle to support the Seattle location and other locations. Contoso recently deployed a Windows Server 2019 server and client infrastructure.

Because of many physical servers being currently underutilized, the company plans to expand virtualization to optimize the environment. Because of this, you decide to perform a proof of concept to validate how Hyper-V can be used to manage a virtual machine environment. Also, the Contoso DevOps team wants to explore container technology to determine whether they can help reduce deployment times for new applications and to simplify moving applications to the cloud. You plan to work with the team to evaluate Windows Server containers and to consider providing Internet Information Services (Web services) in a container.

Objectives

After completing this lab, you’ll be able to:

  • Create and configure VMs.
  • Install and configure containers.

Estimated Time: 60 minutes

Lab Setup

Virtual Machines: WS-011T00A-SEA-DC1, WS-011T00A-SEA-ADM1, and WS-011T00A-SEA-SVR1

User Name: Contoso\Administrator

Password: Pa55w.rd Note that Internet access is required to successfully complete the second exercise in this lab.

Lab Startup

  1. Select SEA-DC1.
  2. Sign in by using the following credentials:
    • User name: Administrator
    • Password: Pa55w.rd
    • Domain: Contoso
  3. Repeat these steps for SEA-ADM1 and SEA-SVR1.

Exercise 1: Creating and configuring VMs

Task 1: Create a Hyper-V virtual switch

  1. On SEA-ADM1, select Start and then select Server Manager.
  2. In Server Manager, select All Servers.
  3. In the Servers list, select and hold (or right-click) or access the context menu SEA-SVR1 and then select Hyper-V Manager.
  4. In Hyper-V Manager, ensure that SEA-SVR1.Contoso.com is selected.
  5. In the Actions pane, select Virtual Switch Manager.
  6. In the Virtual Switch Manager, in the Create virtual switch pane, select Private and then select Create Virtual Switch.
  7. In the Virtual Switch Properties box, enter the following details and then select OK:
    • Name: Contoso Private Switch
    • Connection type: Private network

Task 2: Create a virtual hard disk

  1. On SEA-ADM1, in Hyper-V Manager, select New and then select Hard Disk. The New Virtual Hard Disk Wizard starts.
  2. On the Before you Begin page, select Next.
  3. On the Choose Disk Format page, select VHD and then select Next.
  4. On the Choose Disk Type page, select Differencing and then select Next.
  5. On the Specify Name and Location page enter the following and then select Next:
    • Name: SEA-VM1
    • Location: C:\Base
  6. On the Configure Disk page, in the Location box, enter C:\Base\BaseImage.vhd and then select Next.
  7. On the Summary page, select Finish.

Task 3: Create a virtual machine

  1. On SEA-ADM1, in Hyper-V Manager, select New and then select Virtual Machine. The New Virtual Machine Wizard starts.
  2. On the Before you Begin page, select Next.
  3. On the Specify Name and Location page, enter SEA-VM1 and then select the check box next to Store the virtual machine in a different location.
  4. In the Location box, enter C:\Base and then select Next.
  5. On the Specify Generation page, select Generation 1 and then select Next.
  6. On the Assign Memory page, enter 4096 and then select Next:
  7. On the Configure Networking page, select the Connection drop-down menu, select Contoso Private Switch and then select Next.
  8. On the Connect Virtual Hard Disk page, select Use an existing virtual hard disk, and then select Browse.
  9. Browse to C:\Base, select SEA-VM1.vhd, select Open and then select Next.
  10. On the Summary page, select Finish. Notice that SEA-VM1 displays in the Virtual Machines list.
  11. Select SEA-VM1 and then in the Actions pane, under SEA-VM1, select Settings.
  12. In the Hardware list, select Memory.
  13. In the Dynamic Memory section, select the check box next to Enable Dynamic Memory.
  14. Next to Maximum RAM, enter 4096 and then select OK.
  15. Close Hyper-V Manager.

Task 4: Manage Virtual Machines using Windows Admin Center

  1. On SEA-ADM1, on the taskbar, select Microsoft Edge.
  2. In Microsoft Edge, on the Favorites Bar, select Windows Admin Center.
  3. In the Windows Security box, enter Contoso\Administrator with the password of Pa55w.rd and then select OK.
  4. In the All connections list, select SEA-SVR1.

    Note: You may need to select Manage As to then enter the credentials in the next step.

  5. In the Specify your credentials page, select Use another account for this connection, and then enter Contoso\Administrator with the password of Pa55w.rd.
  6. In the Tools list, select Virtual Machines. Review the Summary pane.
  7. Select the Inventory tab. Notice the two virtual machines.
  8. Select SEA-VM1. Review the Properties pane.
  9. Select Settings and then select Disks.
  10. Select Add disk.
  11. Select Create an empty virtual hard disk and then in the Size box enter 5 GB.
  12. Select Save disks settings and then select Close.

    Note: The Save Disk Setting may be greyed out which is a known issue. A workaround would be to create the disk in Hyper-V if needed.

  13. On the Properties page, select Start to start SEA-VM1.
  14. Scroll down and display the statistics for the running VM.
  15. Refresh the page and then select Shut down. Select Yes to confirm.
  16. In the Tools list, select Virtual switches. Notice the two switches that have been configured.
  17. Close all open windows on SEA-ADM1.

Exercise 1 results

After this exercise, you should have used Hyper-V Manager and Windows Admin Center to create a virtual switch, create a virtual hard disk, and then create and manage a virtual machine.

Exercise 2: Installing and configuring containers

Task 1: Install Docker on Windows Server

  1. On SEA-ADM1, from the taskbar, open Microsoft Edge.
  2. On the Favorites bar, select Windows Admin Center.
  3. In the Windows Security box, enter the following credentials:

    • User name: Contoso\Administrator
    • Password: Pa55w.rd
  4. On the All connections page, select SEA-SVR1.
  5. On the Specify your credentials page, select Use another account for this connection. Provide the Contoso\Administrator credentials, and then select Continue.
  6. In the Tools list, select PowerShell. Provide the Contoso\Administrator credentials, and then select Enter. You are now connected to SEA-SVR1 using a Remote PowerShell connection.

    Note: The Powershell connection in WAC may be slow due to nested virtualization used in the lab, so an alternate method is to use Enter-PSSession -computername SEA-SVR1 from a Powershell window on SEA-ADM1.

  7. At the PowerShell command prompt enter the following command and then select Enter:

    Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

  8. At the NuGet Provider prompt, enter Y for yes and then select Enter.
  9. At the PowerShell command prompt enter the following command and then select Enter:

    Install-Package -Name docker -ProviderName DockerMsftProvider

  10. At the confirmation prompt, enter A for Yes to All and then select Enter.
  11. After the installation is complete, restart the computer by using the following command:

    Restart-Computer -Force

Task 2: Install and run a Windows container

  1. After SEA-SVR1 restarts reconnect the PowerShell tool and provide the Contoso\Administrator credentials.
  2. Verify the installed version of Docker by using the following command:

    Get-Package -Name Docker -ProviderName DockerMsftProvider

    Note: You may need to run Start-Service -name Docker before running the next commands.

  3. To verify whether any Docker images are currently pulled, use the following command:

    Docker images

    Notice that there are no images in the local repository store.

  4. To review docker base images from the online Microsoft repository, use the following command:

    Docker search Microsoft

    Notice the variety of base images each representing various runtime scenarios.

    Note: You may disregard any errors and continue with the next step.

  5. To download a server core image, with IIS, that matches the host operating system, run the following command:

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

    Note: This download may take more than 15 minutes to complete.

  6. To confirm the Docker image that is currently pulled, use the following command:

    Docker images

    Notice that there is now an image listed in the local repository store.

  7. To run the container, enter the following command:

    Docker run -d -p 80:80 --name ContosoSite mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 cmd

    This command runs the IIS image as a background service (-d) and configures networking such that port 80 of the container host maps to port 80 of the container.

  8. Enter the following command to retrieve the IP address information of the container host:

    ipconfig

    Note the IPv4 address of the Ethernet adapter named vEthernet (nat). This is the address of the new container. Make a note of the IPv4 address of the Ethernet adapter named Ethernet. This is the IP address of the Host (SEA-SVR1).

  9. In Microsoft Edge, open another tab and then enter <http://172.16.10.12>. Observe the default IIS page.

  10. In the remote PowerShell session, enter the following command:

    docker ps

    This command provides information on the container that is currently running on SEA-SVR1. Take note of the container ID as you will use it to stop the Container.

  11. In the remote PowerShell session, enter the following command:

    docker stop <ContainerID>

  12. Rerun the docker ps command to confirm that the container has stopped.

Task 3: Use Windows Admin Center to manage containers

  1. On SEA-ADM1, ensure that SEA-SVR1 is targeted in the Windows Admin Center and then select the Containers tool.
  2. Browse through each of the Summary, Containers, Images, Networks, and Volumes tabs.

Exercise 2 results

After this exercise, you should have installed Docker on Windows Server and installed and run a Windows container containing web services.