3

Trying to install Docker in process isolation on Windows Server 2019 and following these steps. (I can't use Hyper-V on this server) when running PowerShell in admin mode.

I however get the error

Get-PackageProvider : A parameter cannot be found that matches parameter name 'ListAvailableget-packagesource' enter image description here

I also tried Install-Package -Name docker -ProviderName DockerMsftProvider I then get:

Install-Package : Unable to find package providers (DockerMsftProvider).
At line:1 char:1
+ Install-Package -Name docker -ProviderName DockerMsftProvider
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], E
   xception
    + FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Install-Package : Unable to find package providers (DockerMsftProvider).
At line:3 char:1
+ Install-Package -Name docker -ProviderName DockerMsftProvider
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], E
   xception
    + FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

UPDATE 1

I had to set the PowerShell execution policy to unrestricted like so (I'll set it back to Restricted Set-ExecutionPolicy -ExecutionPolicy Restricted after all this):

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

I also had to temporarily disable some antivirus/malware protection from Windows Defender. For me antimalware was already disabled so I had to also disable real-time virus protection.

I then could run

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Now via Get-PackageProvider -ListAvailable I see that DockerMsftProvider is installed.

Name                     Version          DynamicOptions
----                     -------          --------------
DockerMsftProvider       1.0.0.8          Update
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

I ran Install-Package -Name docker -ProviderName DockerMsftProvider and entered Y.

I then run Get-Package -Name Docker -ProviderName DockerMsftProvider and get:

Name                           Version          Source                           ProviderName
----                           -------          ------                           ------------
docker                         20.10.0          DockerDefault                    DockerMsftProvider

When I run Install-Package -Name docker -ProviderName DockerMsftProvider I get no feedback via PowerShell, no errors, so I think it's good.

However, when I checked here and ran docker run --isolation=process mcr.microsoft.com/windows/nanoserver:1809 cmd.exe /c ping 127.0.0.1 -t

I get the error

docker : The term 'docker' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ docker run --isolation=process mcr.microsoft.com/windows/nanoserver:1 ...
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (docker:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

In the past I had tried to install Docker Desktop, which I then uninstalled since my VPS does not support Hyper-V. I'm not sure if this is still from that install or new, but I added path C:\Program Files\Docker to my environment PATH variable.

enter image description here

Still I get the same error

The term 'docker' is not recognized as the name of a cmdlet, function, script file, or operable program.

UPDATE 2

Based on @Peter Wishart's answer I checked my PATH system variables, but Docker can be seen there (see screenshot below) and as Peter also mentioned, since I can run docker --version via the command prompt (not PowerShell) the install did complete successfully.

enter image description here

UPDATE 3
I checked ($env:path).Split(";") in PowerShell and the Docker path is there: enter image description here

How can I install Docker?

Adam
  • 6,041
  • 36
  • 120
  • 208

1 Answers1

3

I use a script that installs the containers feature and uninstalls Windows Defender (n.b. this may or may not be safe for your environment):

$rebootNeeded = $false
if (-not (Get-WindowsFeature Containers).Installed) {
  $rebootNeeded = $rebootNeeded -or (Install-WindowsFeature -Name Containers).RestartNeeded
}

if ((Get-WindowsFeature Windows-Defender).Installed) {
  $rebootNeeded = $rebootNeeded -or (Uninstall-WindowsFeature Windows-Defender).RestartNeeded
}

if ($rebootNeeded) { throw "Reboot then rerun to complete docker installation" }

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
Start-Service docker  
docker --version

I mention this in case its an option to just reset the machine if nothing else works...

I think your first problem was a copy/paste error at the Get-PackageProvider step.

The files you listed are the correct ones for the latest DockerEE version.

If you run docker directly from there e.g. &"C:\Program Files\Docker\docker.exe" --version and it doesn't work, then there's an environmental problem other than the path - try reinstalling Docker.

If you restart Powershell and run ($env:path).Split(";"), the only Docker entry should be C:\Program Files\Docker - perhaps there are some leftovers from Docker Desktop interfering?

[Edit]

It appears that the system path was corrupted in a subtle way (although the docker path was present and correct).

I think if you check the path configuration carefully and/or move the docker path nearer the start of the path, you should be able to get a permanent fix.

Peter Wishart
  • 11,600
  • 1
  • 26
  • 45
  • Thanks! I tested the environment setup: If I run `($env:path).Split(";")` I see "C:\Program Files\Docker" as the only path reference to docker. I used `cmd`, navigate to folder "C:\Program Files\Docker" and run `docker --version` I see "Docker version 20.10.0, build 6ee42dc". I'm not sure if I still need to try your script as the environment seems to be setup correctly? If not, what else could I try? – Adam Apr 18 '21 at 10:52
  • 1
    The script works for me on a new Server 2019 instance. Seeing the correct `docker --version` means that docker is installed ok. I can reproduce the error you get by running `$env:path=":C:\Program Files\Docker"` then trying to run docker (n.b. invalid char at start). If I then run `$env:path="C:\Program Files\Docker"`, Powershell can find docker, so I think the problem is with the path variable. – Peter Wishart Apr 18 '21 at 15:28
  • Ah ok, so no need for me to try that script, since install did complete successfully. Please see my update 2, where I double checked the path variable. – Adam Apr 19 '21 at 04:10
  • Its not clear if you tried the setting of `$env:path` I suggest above, which I think should show that its the "effective path" in powershell that is the problem. – Peter Wishart Apr 19 '21 at 08:27
  • I added update 3 to GET the path in PowerShell (based on your suggestion) which seems ok. I don't see where you SET the path for PowerShell in your answer? – Adam Apr 19 '21 at 09:25
  • Sorry yes the setting of the path was in my first comment. You could try the two versions (invalid and valid path) and verify you see the same as me. NB you'll need to restart powershell to undo the setting of the path like that. – Peter Wishart Apr 19 '21 at 09:39
  • I have no idea why, but it now works and `docker` command is recognized in PowerShell...I think fiddling with the path like you suggested may have worked, thanks, I'll award the bounty :) I do run into another issue right now though, if you could have a look? https://stackoverflow.com/questions/67160140/docker-error-during-connect-in-the-default-daemon-configuration-on-windows-th – Adam Apr 19 '21 at 10:22