0

I need hyper-v inside a docker container using the image mcr.microsoft.com/windows/servercore:ltsc2019-amd64. When I to enable it by using Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart it fails with:

Install-WindowsFeature : The request to add or remove features on the specified server failed.  
Installation of one or more roles, role services, or features failed.
The source files could not be found. 
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see 
http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f081f
At line:1 char:1
+ Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:PSObject) [Install-WindowsFeature], Exception
    + FullyQualifiedErrorId : DISMAPI_Error__Failed_To_Enable_Updates,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
False   No             Failed         {}

But if I install this role Install-WindowsFeature -Name Hyper-V-PowerShell -IncludeManagementTools

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             NoChangeNeeded {}

it works perfectly. Is there a hardware / nested virtualization requirement that I'm not aware of?

LowRez
  • 125
  • 2
  • 14
  • Hi Jing. I assume you wanted to run Docker daemon inside Windows container? Have you had any success with this? Dealing with similar Docker in Docker scenario in Windows container. I can install Docker daemon and use "Install-WindowsFeature -Name Hyper-V-PowerShell -IncludeManagementTools" command but Docker doesn't run. The error is "failed to start daemon: failed to load vmcompute.dll, ensure that the Containers feature is installed" – GGG Jun 21 '22 at 02:16
  • Hi @GGG, unfortunately we had to switch to a different solution for our use case. As stated in the answer by Vinicius, I don't think it's possible to enable Hyper-V in a windows container. If you find a way to do it, please add it here. – LowRez Aug 23 '22 at 08:01

1 Answers1

2

Hyper-V is not supported inside of Windows containers and for that reason the bits for its installation were removed. That's why the first command gives you an error. The second feature you are installing is the PowerShell module for Hyper-V. That module allows you to manage a Hyper-V node from PowerShell - which you can do from a Windows container, hence the success output.

PS C:\Users\Microsoft> Get-WindowsFeature -Name *hyper*                                                              
Display Name                                            Name                       Install State
------------                                            ----                       -------------
[ ] Hyper-V                                             Hyper-V                        Available
        [ ] Hyper-V Management Tools                    RSAT-Hyper-V-Tools             Available
            [ ] Hyper-V GUI Management Tools            Hyper-V-Tools                  Available
            [ ] Hyper-V Module for Windows PowerShell   Hyper-V-PowerShell             Available

If you don't mind me asking: what is the scenario that requires you to have Hyper-V installed in a Windows container?

  • 1
    We're trying to create a gitlab CI pipeline that makes custom windows images with cloudbase-init for MaaS deployment. Every month it would create an image with the latest updates. It seems that we're forced to use a shell executor rather than a container environment now. – LowRez Jun 03 '22 at 09:22