Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to run the Linux container on Windows

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to run Linux container on Windows". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to run Linux container on Windows".

1. Overview

You can now run the Docker container on Windows 10 and Windows servers, which is based on Ubuntu as the host.

Imagine using your favorite Linux distribution-such as Ubuntu-- to run your own Linux application on Windows.

Now, with the help of Docker technology and the power of Hyper-V virtualization on Windows, this is possible.

2. Pre-demand

You need a 64-bit x86 PC in 8GB memory to run Windows 10 or Windows Server.

Only if you join the Windows Preview experience Program (Insider) can you run a Linux container with Hyper-V support. This program allows you to test pre-release software and upcoming Windows.

If you are particularly concerned about stability and privacy (the Windows Preview experience program allows Microsoft to collect usage information), you can consider waiting for the release of Windows 10 Fall Creator update in October 2017, which allows you to use Docker technology with Hyper-V support without having to Windows preview experience identity.

You also need a * * version of Docker, which can be downloaded from http://dockerproject.org.

*, you also need to make sure that you have installed the XZ tool, which is needed to extract the image of the Ubuntu host container.

3. Join the Windows Preview experience Program (Insider)

If you are already a member of Windows Preview experience Project (Insider), you can skip this step. Otherwise, open the following link in the browser:

Https://insider.windows.com/zh-cn/getting-started/

To register for the program, log in using your Microsoft personal account in Windows 10 and click "sign up" on the home page of the preview experience program to accept the terms and complete the registration.

Then you need to open the "Update and Security" menu in the Windows start menu and select "Windows Preview experience Plan" on the left side of the menu.

If necessary, click the "repair" button when Windows prompts "your Windows Preview experience Program account needs attention".

4. Content of Windows Preview experience (Insider)

From the Windows preview experience plan panel, select "get started". If your Microsoft account is not associated with your Windows 10 system, log in using the account you want to associate with when prompted.

Then you can choose what you want to receive from the Windows Preview experience program. To get the Hyper-V isolation function required by Docker technology, you need to add the "fast circle" and restart Windows after two confirmations. After restarting, you need to wait for your machine to install various updates before you can proceed to the next step.

5. Install Docker for Windows

Download Docker for Windows from Docker Store.

After the download is complete, install and restart as needed.

After rebooting, Docker has already started. Docker requires Hyper-V to be enabled, so it will prompt you to enable and restart. Click "OK" to enable it for Docker and restart the system.

6. Download Ubuntu container image

Download the Ubuntu container image for Windows from the Canonical partner image website.

After downloading, use the XZ tool to extract:

C:\ Users\ mathi\ >.\ xz.exe-d xenial-container-hyper-v.vhdx.xz C:\ Users\ mathi\ >

7. Prepare the container environment

First create two directories:

Create C:\ lcow, which will be used for temporary space when Docker prepares the container.

Create another C:\ Program Files\ Linux Containers, which is where the Ubuntu container image is stored.

You need to give this directory additional permissions to allow Docker to use mirrors in it. Run the following Powershell script in the Powershell window with administrator privileges:

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 it as set_perms.ps1 and run it.

Hint, you may need to run Set-ExecutionPolicy-Scope process unrestricted to allow unsigned Powershell scripts to be run.

C:\ Users\ mathi\ >.\ set_perms.ps1 "C:\ Program Files\ Linux Containers" C:\ Users\ mathi\ >

Now, copy the Ubuntu container image (.vhdx) obtained from the previous step to uvm.vhdx under C:\ Program Files\ Linux Containers.

8. More preparations for Docker

Docker for Windows requires some pre-released features to work with Hyper-V isolation. These features are not available in previous versions of Docker CE, and the required files can be downloaded from master.dockerproject.org.

Download dockerd.exe and docker.exe from master.dockerproject.org and put them in a safe place, such as your own folder. They are used to start the Ubuntu container in the next step.

9. Run the Ubuntu container on Hyper-V

You are now ready to activate your container. First open the command line (cmd.exe) as an administrator, and then start dockerd.exe with the correct environment variables.

C:\ Users\ mathi\ > set LCOW_SUPPORTED=1 C:\ Users\ mathi\ >.\ dockerd.exe-D-- data-root C:\ lcow

Then, launch the Powershell window as an administrator and run docker.exe to pull the image for your container:

C:\ Users\ mathi\ >.\ docker.exe pull ubuntu

Now that you've finally started the container, run docker.exe again to run the new image:

C:\ Users\ mathi\ >.\ docker.exe run-it ubuntu

Congratulations! You have successfully got your system running a container with Hyper-V isolation on Windows, and you are running a Ubuntu container that you like very much.

10. Get help

If you need some guidance on how to get started with Hyper-V Ubuntu containers, or if you have problems, you can ask for help here:

Ask Ubuntu

Ubuntu Forums

IRC-based support

Thank you for reading, the above is the content of "how to run Linux container on Windows". After the study of this article, I believe you have a deeper understanding of how to run Linux container on Windows, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report