Windows 容器快速入门:安装容器主机.ps1 失败,并显示消息"Image NanoServer not found after 5 minutes"



注意:GitHub上已经报告了这个问题,但到目前为止还没有任何解决方案。

平台信息:ESX 6.0上支持Hyper-V的Windows 2016 Server TP4 guest,具有6GB RAM和80GB硬盘。

我遵循了"将Windows容器主机部署到新的Hyper-V虚拟机"快速启动,但该过程总是失败,如下所示:

PS C:Windowssystem32> powershell.exe -NoProfile c:New-ContainerHost.ps1 -VMName testcont -WindowsImage ServerDatacenterCore -Hyperv
    cmdlet New-ContainerHost.ps1 na posição de comando 1 do pipeline
    Forneça valores para os seguintes parâmetros:
    Password: ********
    Before installing and using the Windows Server Technical Preview 4 with Containers virtual machine you must:
        1. Review the license terms by navigating to this link: http://aka.ms/tp4/containerseula
        2. Print and retain a copy of the license terms for your records.
    By downloading and using the Windows Server Technical Preview 4 with Containers virtual machine you agree to such license terms. Please confirm you have accepted and agree to the license terms.
    [N] No  [Y] Yes  [?] Ajuda (o padrão é "N"): y
    Using VHD path C:UsersPublicDocumentsHyper-VVirtual Hard Disks
    Using external switch vmxnet3 Ethernet Adapter - Virtual Switch
    The latest ServerDatacenterCore VHD is already present on this system.
    ServerDatacenterCore Container OS Image (WIM) is already present on this system.
    Creating VHD files for VM testcont...
VHD mount must be synchronized with other running instances of this script.  Waiting for exclusive access...
Mounting ServerDatacenterCore VHD for offline processing...
Enabling Containers feature on drive F...
Enabling Hyper-V feature on drive F...
Copying Docker into ServerDatacenterCore VHD...
Copying NSSM into ServerDatacenterCore VHD...
This script uses a third party tool: NSSM. For more information, see https://nssm.cc/usage
Downloading NSSM...
Extracting NSSM from archive...
Writing default unattend.xml...
Copying Install-ContainerHost.ps1 into ServerDatacenterCore VHD...
Dismounting VHD...
Creating VM testcont...
Configuring VM testcont...
Connecting VM to switch vmxnet3 Ethernet Adapter - Virtual Switch
AVISO: A virtualização aninhada é um recurso de visualização sem suporte. Os hipervisores que não forem o hipervisor do
 Hyper-V em execução em uma máquina virtual convidada provavelmente falharão. Além disso, alguns recursos do Hyper-V
são incompatíveis com a virtualização aninhada, como memória dinâmica, pontos de verificação e salvar/restaurar.
Starting VM testcont...
Waiting for VM testcont to boot...
Connected to VM testcont Heartbeat IC.
Waiting for specialization to complete (this may take a few minutes)...
Executing Install-ContainerHost.ps1 inside the VM...
Completing container install...
Querying status of Windows feature: Containers...
Feature Containers is already enabled.
Querying status of Windows feature: Hyper-V...
Feature Hyper-V is already enabled.
Waiting for Hyper-V Management...
Enabling container networking...
Creating container switch (NAT)...
Creating NAT for 172.16.0.0/24...
Installing Container OS image from D:WindowsServerCore.wim (this may take a few minutes)...
Container base image install complete.  Querying container images...
C:Install-ContainerHost.ps1 : Image NanoServer not found after 5 minutes
At line:1 char:1
+ C:Install-ContainerHost.ps1 -PSDirect -NATSubnetPrefix 172.16.0.0/24 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-ContainerHost.ps1
C:New-ContainerHost.ps1 : Install-ContainerHost.ps1 failed in the VM
No linha:1 caractere:1
+ c:New-ContainerHost.ps1 -VMName testcont -WindowsImage ServerDatacen ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-ContainerHost.ps1

我很无助。如有任何帮助,我们将不胜感激。

我必须自己解决这个问题,这样我才能告诉你我必须做什么…

问题是Install-ContainerHost.ps1中的一行,它是New-Container Host.ps1 运行的文件

你可以从这里获得安装文件

里面有下面一行需要更换以阻止错误的发生:

$newBaseImages = Get-InstalledContainerImage $BaseImageName

该行可以替换为以下行:

$newBaseImages = Get-ContainerImage

完成并保存了它(我将我的文件与New-ContainerHost.ps1一起保存在C:中),然后您可以通过在运行的命令中包含-ScriptPath选项来告诉New-ContalinerHost.ps1文件使用它:

powershell.exe -NoProfile c:New-ContainerHost.ps1 -VMName testcont -WindowsImage ServerDatacenterCore -Hyperv -ScriptPath C:Install-ContainerHost.ps1

另一件需要注意的事情是,您可能需要使用Set-ExecutionPolicy临时修改您的执行策略,或者在Powershell允许您运行它之前签署修改后的ps1文件,这取决于您的系统的执行策略当前设置为什么。

这是给我的。希望对你有帮助。

最新更新