OneGet / MicrosoftDockerProvider

Provider to search, save and install Docker
Other
133 stars 55 forks source link

Windows 10 support still bug #30

Open yamauchikazu opened 7 years ago

yamauchikazu commented 7 years ago

There are still some bugs in DockerMsftProvider's Windows 10 support. DockerMsftProviderInsider for Insider Container also have same bugs.

"Install-Package -Name Docker -ProviderName DockerMsftProvider" still try to execute "Get-WindowsFeature" and rise error. "Get-WindowsOptionalFeature" code for Windows 10 is not executed becase "Get-wmiobject -class win32_operatingsystem" return not "Microsoft Windows 10" but "Microsoft Windows 10 ".

And "Enable-WindowsOptionalFeature" and "Disable-WindowsOptionalFeature" cmdline need "-Online" option to support Windows 10.

To Fix bugs: (1) switch(Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption ){
'Microsoft Windows 10' -> switch -wildcard (Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption ){
'Microsoft Windows 10 *' (2) Enable-WindowsOptionalFeature -FeatureName Containers -> Enable-WindowsOptionalFeature -FeatureName Containers -Online (3) Disable-WindowsOptionalFeature -FeatureName Containers -> Disable-WindowsOptionalFeature -FeatureName Containers -Online

brwilkinson commented 7 years ago

Here is some code that I used. . .

    if ($PSVersionTable.PSEdition -EQ 'Desktop')
    {
        # Check on Desktop Edition
        $containerExists = Get-WindowsOptionalFeature -Online -FeatureName containers
        if($containerExists -and ($containerExists.State -EQ 'Enabled'))
        {
            Write-Verbose "Containers feature is already installed. Skipping the install."
            return
        }
        else
        {
            Write-Verbose "Installing Containers..."
            $null = Enable-WindowsOptionalFeature -Online -FeatureName containers
            $script:restartRequired = $true            
        }            
    }
    else
    {

        # Check on Server SKU
        $containerExists = Get-WindowsFeature -Name Containers
        if($containerExists -and $containerExists.Installed)
        {
            Write-Verbose "Containers feature is already installed. Skipping the install."
            return
        }
        else
        {
            Write-Verbose "Installing Containers..."
            $null = Install-WindowsFeature containers
            $script:restartRequired = $true            
        }

    }
slonopotamus commented 2 years ago

You might want to take a look at Stevedore project as a way to install modern Docker for Windows containers on both Windows Server/Client.