Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Docker Windows Server 2019: the term 'docker' is not recognized as the name of a cmdlet, function, script file, or operable program

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?

like image 995
Adam Avatar asked Oct 16 '25 16:10

Adam


2 Answers

For who face the problem in year 2024

While execute PowerShell command "Install-Package -Name docker -ProviderName DockerMsftProvider -Force" Then it return error not found!

The reason is this service has been shut down since May 23rd 2023 Thanks for Mattes, Claudio-GMZ

You just use this command to install docker with PowerShell instead

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1
.\install-docker-ce.ps1

references

https://learn.microsoft.com/en-us/answers/questions/1324697/install-package-docker-windows-server-2022-error

https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1

like image 107
ice thailand Avatar answered Oct 18 '25 06:10

ice thailand


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.

like image 44
Peter Wishart Avatar answered Oct 18 '25 08:10

Peter Wishart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!