You can of course just install Docker Desktop, but there are situation where you don't want / can't use it.
So its good to know that you actually don't need to and can isntead intall only the docker binaries. The only drawback is that it only allows you to use Windows images with now option to switch to linux based images.
As of docker-cli >= v24.0.2
you can also install via the winget
tool. That makes it significantly easier, but gives you less contoll. So I am leaving the rest up here.
winget install --id Docker.DockerCli
Note The following assuemes that you are working in a
PowerShell
terminal sesstion with administrative rights.
You need Hyper-V to use docker. Run this to ensure you have it:
Enable-WindowsOptionalFeature -Online -FeatureName containers –All
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All
You might need to resart the PC.
Docker publishes the binaries, you just need to know where to find them.
Run this handy command to get a list of avalable files:
$url = 'https://download.docker.com/win/static/stable/x86_64/'
(curl $url).Links | ForEach-Object {$url + $_.href}
select the version you want to get from the list.
First create the Directory Docker should live in (don't change into it!):
mkdir docker
Than download the ZIP-archive and extract its content:
curl.exe -o docker.zip -L 'SELECTED URL'
Expand-Archive docker.zip -DestinationPath .
rm docker.zip
For the following steps, switch to a powershell with administrative rights.
You probably want access to the docker
command from anywhere, so add the new folder to the enviroment PATH
:
[Environment]::SetEnvironmentVariable("Path", "$($env:path);$(Resolve-Path Docker)", [System.EnvironmentVariableTarget]::Machine)
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
You can manyally start dockerd
whenever you need it, but it is more convenient if its just allways running. So you can register it as a service and have that running allways.
As docker uses a named pipe on windows, you need to grant access to this for all useres that require it. This can be only your usernam, a custom group you create, or simply all users. Pass this in as the --group
argument (even if its just a username). I am going to allow all users:
dockerd --register-service --group=Users
Start-Service docker
Note
Default group names depend on you language setting, soUsers
will only work on systems that where set up using the english language. So adjust acordingly.
Lets run the docker 'hello world':
docker run hello-world