Hi, Habr! A week ago I
told you about a new feature that is available in the Docker and Windows Server / Windows 10 preliminary releases - launching Linux containers with Hyper-V isolation, similar to Windows containers with Hyper-V isolation. This walkthrough will cover a similar launch of containers with Ubuntu in this environment.

Introduction
As I wrote before kata, Docker containers can now be run on Windows 10 and Windows Server, using Ubuntu as a hosting environment. In other words, thanks to the sharing of Docker technology and virtualization of Hyper-V in Windows, you can run your own Linux applications in Windows using - Ubuntu!

')
Requirements
1. You will need an x86 PC with a 64-bit processor and 8 GB of RAM running under Windows 10 or Windows Server.
2. Only Linux members of
the Windows Preliminary Evaluation Program can run Linux containers in Hyper-V. This program allows you to test pre-releases of software and future versions of Windows.
3. If stability and confidentiality are important for your deployment (Windows Pre-Evaluation allows Microsoft to collect usage information), better wait until
Windows 10 Fall Creator Update is released in October 2017. In this release, Docker technology with Hyper-V will be available without the need for participation in her.
4. You will also need the latest Docker release, you can download it from here:
http://dockerproject.org .
5. Finally, you need to make sure that you have installed a program to unzip the Ubuntu container-host image, for example,
7-Zip or
XZ Utils .
How to join the Windows preliminary assessment program
If you are already a member of this program, go to the next step.Stage I :
1. Open the following link in your web browser:
https://insider.windows.com/en-us/getting-started/ .
2. To register, sign in using the same Microsoft account you use to sign in to Windows 10, and click the Register your personal account link on the start page of the Windows Preliminary Evaluation Program. Please accept the terms and conditions to complete the registration.
3. Now you need to open Settings in the Start menu of Windows 10, select Updates & Security (Updates and Security), and then Windows Insider Program from the menu on the left.
4. If necessary, click the Fix me button if Windows issues a warning about your Windows Insider program needs attention.
Stage II :
1. On the Windows Insider Program panel, click Get Started. If your Microsoft account is not associated with your copy of Windows 10, log in when prompted and select the account you want to associate with the installed copy of the operating system.
2. Now you can choose which content you want to receive as a member of the Windows Pre-Evaluation Program. To ensure the availability of isolation tools in Hyper-V that are required by the Docker technology, select Fast. Double-click Confirm, then let Windows restart your computer. After the reboot, you will most likely have to wait for the installation of a certain number of updates before proceeding to the next step.

Install Docker for Windows
1. Download Docker for Windows from the
Docker Store .
2. After downloading, complete the installation and reboot the system when prompted.
3. After the reboot, the Docker will start. Docker uses the Hyper-V feature, so if necessary, it will ask you to turn it on and perform a reboot. Click OK to enable Docker to enable Hyper-V and reboot the system.

Download Ubuntu Container Image
1. Download the latest Ubuntu container for Windows image from
the Canonical Partner Images website .
2. Unzip the downloaded image using 7-Zip or XZ Utils:
C:\Users\mathi\> .\xz.exe -d xenial-container-hyper-v.vhdx.xz
Prepare the environment for the container
1. First create two directories.
2. Create a directory
C: \ lcow , which will be used as a temporary file area for Docker when preparing containers.
3. Also create the directory
C: \ Program Files \ Linux Containers . It will store the image of the container Ubuntu.
4. You will need to assign additional permissions to this directory so that Docker can use the images stored in it. Run the following Powershell script in the Powershell admin window:
param( [string] $Root ) # Give the virtual machines group full control $acl = Get-Acl -Path $Root $vmGroupRule = new-object System.Security.AccessControl.FileSystemAccessRule("NT VIRTUAL MACHINE\Virtual Machines", "FullControl","ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($vmGroupRule) Set-Acl -AclObject $acl -Path $Root
Save this file as
set_perms.ps1 and run it.
TIP . You may need to run the
Set-ExecutionPolicy -Scope process unrestricted
to run unsigned Powershell scripts.

C:\Users\mathi\> .\set_perms.ps1 "C:\Program Files\Linux Containers" C:\Users\mathi\>
5. Now copy the Ubuntu container image file (
.vhdx ), unzipped in the previous step, name it
uvm.vhdx and place it in the
C: \ Program Files \ Linux Containers directory.
Additional Preparatory Steps for Docker
1. Docker for Windows requires some pre-release features for working with Hyper-V isolation tools. These features are not yet available in the previously installed Docker CE, but you can download the necessary files from
http://master.dockerproject.org .
2. Download the dockerd.exe and docker.exe files from
http://master.dockerproject.org and save in a safe place, such as your own directory. They will be needed to launch the Ubuntu container in the next step.
Launch Ubuntu Container in Hyper-V
1. Now you are ready to launch your container. To get started, open the command line interface (cmd.exe) as administrator and run dockerd.exe in the right environment.
C:\Users\mathi\> set LCOW_SUPPORTED=1 C:\Users\mathi\> .\dockerd.exe -D --data-root C:\lcow
2. Then open the Powershell window as an administrator and run docker.exe to download the image for your container.
C:\Users\mathi\> .\docker.exe pull ubuntu
3. Finally, it is time to launch the container. Run
docker.exe again and ask the system to deploy a new image.
C:\Users\mathi\> .\docker.exe run -it ubuntu
Congratulations! You have successfully configured your system to work with containers with Hyper-V isolation in Windows and run your own Ubuntu container.
Help
If you need help getting started with the images of the Ubuntu Hyper-V container or if you have problems, support is always there: