Manually installing Docker on Windows Server 2019
Seemingly impossible task
I had to install Docker with Linux containers on a machine with Windows Server 2019 installed. This machine was completely isolated — no internet access. As I am software dev and not dev-ops engineer or sys admin I was really struggling. And the world of Microsoft Windows Server is something I am really not familiar with. I will try to share with you short tl:dr guide/recipe on how to install Docker on Windows Server without internet access and switch to Linux Containers mode. It won’t be the best and the perfect way to do it, but this recipe will work.
Where are web articles when you need them?
I had a problem to find good article about installing Docker and switching to Linux Containers. There is a lot of articles but none of them seem to completely solve all the issues. Some were outdated and some solutions were just not working. And when it came to installing it manually without internet and without all those fancy powershell commands that is when the trouble began. Some articles suggest using DockerProvider but it is no longer maintained and is not needed.
Installing Docker EE
You need a Windows 10 machine with an access to the internet (The target machine won’t have it) and you will need Powershell (I use Windows Terminal with Powershell). The target machine (Windows Server machine) should have Hyper-V capabilites as well as container capabilites.
1. Download Docker package
On your Windows 10 machine Install DockerMsftProvider
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
After it installs you need to save Docker package locally
Save-Package -Name Docker -Path ~\Wherever\YouNeed\Path -ProviderName DockerMsftProvider
Copy .zip folder of the package to the target machine (a machine with the Windows Server). Extract copied .zip to the C:\Windows\System32\ path after that you should have docker folder present in there. Add this “docker” folder to the path variable.
2. Add required features
Using Server Manager you should be able to add features. You should select “Hyper-V” role. You should add “containers”, “Hyper-V”, “windows subsystem linux” features. (complete installation, restart the machine)
3. Add LCOW linux kernel
On your Windows 10 machine download lcow newest release:
Invoke-WebRequest -Uri "https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip" -UseBasicParsing -OutFile release.zip
Copy this release file .zip folder to the target machine. And extract .zip to the C:\Program Files\Linux Containers folder.
Switching to the Linux containers
If you added docker folder to the path you should be able to write:
dockerd --register-service --experimental
Start-Service docker
This will create docker service and turn on experimental mode. If you had registered service before and started it, you should stop docker service unregister it, restart machine and then register again with the “experimental” parameter.
Stop-Service docker
dockerd --unregister-service
dockerd --register-service --experimental
Start-Service docker
After that you can finally switch to linux container with this command:
[System.Environment]::SetEnvironmentVariable(
"LCOW_SUPPORTED", "1", [System.EnvironmentVariableTarget]::Machine)
If you do not want to specify platform everytime you run container you should also include additional environment variable:
[System.Environment]::SetEnvironmentVariable(
"LCOW_API_PLATFORM_IF_OMITTED", "linux",[System.EnvironmentVariableTarget]::Machine)
To complete installation restart the docker service:
Restart-Service docker
Loading docker image to the target machine
Assuming you have installed docker on your windows 10 (there shouldn’t be any problem with that) you should be able to pull and save a docker image.
docker pull ubuntu
docker save -o ubuntu_image.docker ubuntu
After you copy this image file to the target machine you can load it and run container:
docker load -i ubuntu_image.docker
docker run --rm --platform=linux ubuntu echo "Hello, World"
Final info
I am by no means a professional when it comes to managing Windows Server. I am not experienced in this area of expertise. (Windows Server, Docker EE) This recipe for installing docker and using linux containers is more of an emergency solution. I tried to write quick guide so it might not be specific enough. I linked some articles on which this guide was based.