I setup a windows docker image and started it on my Windows 10 machine.
In the running docker image registered the gitlab runner at my gitlab server.
The problem is that the gitlab server sees the ip address of the host Windows machine and as a result things it is online.
Is there anyway to run a build runner in an interactive docker image?
Here is my dockerfile
# escape=`
FROM microsoft/windowsservercore
RUN #"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# wait for vs_installer.exe, vs_installerservice.exe
# or vs_installershell.exe because choco doesn't
RUN powershell -NoProfile -InputFormat None -Command `
choco install git 7zip -y; `
choco install visualcpp-build-tools `
-y; `
Write-Host 'Waiting for Visual C++ Build Tools to finish'; `
Wait-Process -Name vs_installer
#WORKDIR C:\build
#CMD powershell -ExecutionPolicy Bypass -Command .\release.ps1
COPY entrypoint.bat entrypoint.bat
# Install Chocolatey
#RUN powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET #"PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# Register the GitLab Runner
COPY gitlab-runner-windows-amd64.exe /gitlab/gitlab-runner.exe
RUN /gitlab/gitlab-runner.exe install
SHELL ["cmd.exe", "/s", "/c", "C:\\entrypoint.bat"]
WORKDIR /code
ENTRYPOINT ["C:\\entrypoint.bat"]
CMD ["cmd"]
EXPOSE 443
and my entrypoint.bat file
#echo off
pushd C:
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"
REM call "C:\Program Files (x86)\Microsoft Visual C++ Build Tools\vcbuildtools.bat"
popd
%*
Here is how I build it
docker build -t windows .
Here is how I run it
docker run -it windows cmd
Here is how I register the gitlab runner
C:\gitlab>gitlab-runner register --non-interactive --name "Windows docker builder" --url "https://gitlabserver/" --registration-token TOKEN --tag-list windows --executor shell
Registering runner... succeeded runner=XXX
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
On the GitLab Server I can see it is register but to it shows the ip address of the Windows 10 host machine not the ip address inside of docker.
Related
Im trying to install Chocolatey into a docker windows container, on a Windows 10 Machine using a Windows Container and not linux containers. Im running the docker build command in the PowerShell console and every time it get to trying to install Chocolatey using the line: Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
It comes back with:
Exception calling "DownloadString" with "1" argument(s): "The remote name could not be resolved: 'chocolatey.org'"
At line:1 char:166
+ ... -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('ht ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
It cant seem to resolve the chocolatey.org part and I'm specifying the network card in my build command:
docker build --network 21fb9a254e4b --progress=plain --tag jcontent/dockerwinbaseimage .
I have also specified the DNS settings in the Daemon file to look at 8.8.8.8 this is in testing it was not working before this....
I have attached my Build Script. Any Help would be appreciated.
# escape=`
FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2016
FROM microsoft/windowsservercore:10.0.14393.1358
RUN #powershell [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
ENV chocolateyUseWindowsCompression=false
RUN #powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco config set cachelocation C:\chococache
RUN choco feature enable --name allowGlobalConfirmation
RUN choco install git;
RUN choco install nodejs;
RUN choco install curl;
RUN choco install docker;
RUN choco install terraform;
# choco install visualstudio2015community --confirm --timeout 216000 \
RUN choco install dotnet4.6.1 --confirm --limit-output;
RUN choco install visualstudio2017enterprise --package-parameters "--passive --locale en-US --includeOptional" --confirm --limit-output --timeout 216000;
RUN choco install visualstudio2017-workload-azure --confirm --limit-output --timeout 21600 --package-parameters "--includeOptional";
RUN choco install visualstudio2017-workload-netcoretools --confirm --limit-output --timeout 21600 --package-parameters "--includeOptional";
RUN choco install visualstudio2017-workload-netweb --confirm --limit-output --timeout 21600 --package-parameters "--includeOptional";
# Destroy Choclotatey cache
RUN rmdir /S /Q C:\chococache
# common node tools
RUN npm install gulp -g && npm install grunt -g && npm install -g less && npm install phantomjs-prebuilt -g;
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Install .NET Core
ENV DOTNET_VERSION 3.1.7
ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/release/1.1.0/Binaries/$DOTNET_VERSION/dotnet-win-x64.$DOTNET_VERSION.zip
RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
RUN Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
RUN Remove-Item -Force dotnet.zip
# Install .NET Core
ENV DOTNET_VERSION 3.1.7
ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/$DOTNET_VERSION/dotnet-win-x64.$DOTNET_VERSION.zip
RUN Invoke-WebRequest $Env:DOTNET_DOWNLOAD_URL -OutFile dotnet.zip; \
RUN Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
RUN Remove-Item -Force dotnet.zip
# Install .NET Core SDK
ENV DOTNET_VERSION 3.1.7
ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-dev-win-x64.$DOTNET_SDK_VERSION.zip
RUN Invoke-WebRequest $Env:DOTNET_SDK_DOWNLOAD_URL -OutFile dotnet.zip; \
RUN Expand-Archive dotnet.zip -DestinationPath $Env:ProgramFiles\dotnet -Force; \
RUN Remove-Item -Force dotnet.zip
SHELL ["cmd", "/S", "/C"]
RUN setx /M PATH "%PATH%;%ProgramFiles%\dotnet"
# Trigger the population of the local package cache
ENV NUGET_XMLDOC_MODE skip
RUN mkdir C:\warmup \
RUN cd C:\warmup \
RUN dotnet new \
RUN cd .. \
RUN rmdir /S /Q C:\warmup
#Change Working Directory to Install DevOps Tools
WORKDIR /azp
#Install DevOps Agents
COPY start.ps1 .
#Configure DevOps Agent
CMD powershell .\start.ps1
I managed to fix this frustrating problem today, here is what I did for when the next person has this issue, as Docker is not going to fix it any time soon.
What I did, is in the desktop app on Windows / Mac you can edit the Daemon file. Under Settings in the Docker App under Docker Engine, I added the line at the bottom of the file just above the last curly brace. "dns": [ "Your DNS Address Here", "8.8.8.8" ]
This then allows the Docker Containers all that you now build to use your host's DNS server. Technically if you can access: https://chocolatey.org/install.ps1 then you should be able to access the choco repository.
I have also built the image in https://github.com/jasric89/vsts-agent-docker/tree/master/windows/servercore/10.0.14393 and labeled it in the repo:
microsoft/windowsservercore:10.0.14393.1358
I then set: RUN choco feature enable --name allowGlobalConfirmation before my first Choco Install command, this enables choco to install all the files and not error.
With all that set my Docker File Ran and built the image. Well in my Test Env now testing in my prod env. :)
Links that helped me:
https://github.com/moby/moby/issues/24928
https://github.com/jasric89/vsts-agent-docker/blob/master/windows/servercore/10.0.14393/standard/VS2017/Dockerfile
https://docs.chocolatey.org/en-us/troubleshooting
https://github.com/moby/moby/issues/25537
UPDATE:
I ran into this problem again on a fresh build and after following my own instructions it didn't quite work.
I realised after a couple more hours of testing that Docker on Windows uses the Hyper-V Network setup.
Within my Hyper V Switch Manager, I did not have a network, with Internet Access. Also when I tried to change the default switch it would not let me. Therefore I had to create a new network within the Hyper-V Network.
I then had to edit the docker Daemon file, in the Docker Settings to tell it to use the right network, and also I put in the DNS settings I specified before in my Anwser.
Here is my full docker daemon file:
{
"registry-mirrors": [],
"insecure-registries": [],
"bridge": "Internet",
"dns": [
"YOUR Local DNS Address Here",
"8.8.8.8"
],
"debug": false,
"experimental": false
}
Thanks to #jason for a great answer which actually helped me a lot to resolve this. In the end, a combination of the Chocolatey install docs and a few other online resources, and I got this to work:
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR /app
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; \
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; \
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'));
RUN choco install dotnetcore-runtime --version 2.2.7 -y;
RUN choco install aspnetcore-runtimepackagestore --version 2.2.7 -y;
I'm trying to install VirtualBox from an electron app to the host machine.
Currently I do the following:
(virtualbox installer is packaged in the electron app)
await util.sudoExec(`
copy ${app.getAppPath()}\\..\\resources\\installers\\VirtualBox-6.1.8-137981-Win.exe ${temp}\\pkg.exe &
${temp}\\pkg.exe /extract --silent &
msiexec /i ${temp}\\VirtualBox\\VirtualBox-6.1.8-r137981.msi /quiet /norestart ALLUSERS=2 VBOX_INSTALLDESKTOPSHORTCUT=0 VBOX_INSTALLQUICKLAUCHSHORTCUT=0
`)
The above code is working 70%. In some cases I got an error message ie.:
'C:\Users\Username\AppData\Local\Temp\pkg.exe' is not recognized as an internal or external command,
operable program or batch file.
I'm not sure this is the best way to install VB.
You could try to use Chocolatey:
This will install it:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
And this command will install Virtualbox:
choco install virtualbox -y
This would also allow you to easily update the software whenever you need to. It's an option so you don't need to maintain package installers for each version of VB.
There is an answer , I think it could help you
'' is not recognized as an internal or external command, operable program or batch file
see the answer of Gerhard on this question
Yo fellow stackoverflow-ers!
I've recently hit a snag when trying to create a windows container that runs IIS. Currently, my dockerfile looks like the following
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-ltsc2016
# Install Powershell
ADD https://github.com/PowerShell/PowerShell/releases/download/v7.0.0/PowerShell-7.0.0-win-x64.zip c:/powershell.zip
RUN powershell.exe -Command Expand-Archive c:/powershell.zip c:/PS7 ; Remove-Item c:/powershell.zip
RUN C:/PS7/pwsh.EXE -Command C:/PS7/Install-PowerShellRemoting.ps1
# Update shell to powershell (PS7)
SHELL ["C:/PS7/pwsh.EXE", "-command"]
# Install chocolatey
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install application dependencies via chocolatey
RUN choco install -y vcredist140
RUN choco install -y nuget.commandline
# Enable required IIS features
RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebSockets;
RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-ApplicationInit;
RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-BasicAuthentication;
RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-WindowsAuthentication;
RUN Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpCompressionDynamic;
# Install IISAdministration to manage IIS configuration
RUN Install-Module -Name IISAdministration -Force -MinimumVersion "1.1.0.0";
# Remove default web site
RUN Remove-IISSite -Name 'Default Web Site'
This results in the following error when the last command is called
Remove-IISSite: The term 'Remove-IISSite' 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.
Note: I'm using PS7, as the current Powershell version that comes with the above container doesn't allow me to install IISAdministration (which is slightly annoying, but hey-ho! Probably something I'm doing wrong).
Any help and/or advice on the current situation would be greatly appreciated!
As per your comment, I have had issues specifically on Server Core 2016 too with PowerShell Modules, so can sympathise. The IISAdministration module has not been ported to .NET Core. You would have to use the current Desktop version of PowerShell i.e. 5.1.
The simplest solution is to use Import-Module IISAdministration -UseWindowsPowerShell instead of Install-Module -Name IISAdministration.
That's how PowerShell 7 loads old modules in the compatible way (a remote session to 5.1),
Reference
I am trying to use chocolatey to install packages into a windows container. I actually just wanted to change one of the packages, rebuild and push and now, suddenly, it doesn't work. When I test it on the host (run the same command as the container) it works just fine. It has some kind of an issue with that container installation since last build. I can only suspect the base image changed. But, maybe not
On the host:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
Creating Chocolatey folders if they do not already exist.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
same host, but this time, in a Dockerfile
PS C:\Users\Administrator\example> cat Dockerfile
# escape=`
ARG SDK_VERSION=4.8
# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:${SDK_VERSION}
# Disable Healthcheck
HEALTHCHECK NONE
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco install adoptopenjdk8openj9jre -y
RUN choco install nuget.commandline -y
RUN choco install yarn -y
RUN choco install gitversion.portable -y
RUN choco install sonarscanner-msbuild-net46 -y
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
PS C:\Users\Administrator\example> docker build -t example .
Sending build context to Docker daemon 4.096kB
Step 1/10 : ARG SDK_VERSION=4.8
Step 2/10 : FROM mcr.microsoft.com/dotnet/framework/sdk:${SDK_VERSION}
4.8: Pulling from dotnet/framework/sdk
65014b3c3121: Already exists
b5405b758079: Pull complete
ac56c610af03: Pull complete
d8d61c2ababf: Pull complete
0ed57babb001: Pull complete
c8a0f45b3421: Pull complete
75cb34f91825: Pull complete
1949a0bb0ffb: Pull complete
316fdf3fc0fa: Pull complete
42b0925a3e5c: Pull complete
c5e384761600: Pull complete
f65f633b9854: Pull complete
bd885be04626: Pull complete
179844769b6b: Pull complete
c037183d4738: Pull complete
Digest: sha256:0008d5d893924c10ec01b1619a009c57116f9a943fe43ca772af544c75c9a83a
Status: Downloaded newer image for mcr.microsoft.com/dotnet/framework/sdk:4.8
---> 99ad7e1e8763
Step 3/10 : HEALTHCHECK NONE
---> Running in f679ce4e5789
Removing intermediate container f679ce4e5789
---> a08984a9afe8
Step 4/10 : RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
---> Running in 656ed514a137
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocInstall...
Unable to unzip package using 7zip. Perhaps try setting
$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:
7-Zip signalled an unknown error (code -1073741511)
At line:220 char:15
+ ... default { throw "$errorMessage 7-Zip signalled an unknown error (co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...de -1073741
511):String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try
setting $env:chocolateyUseWindowsCompression = 'true' and call install aga
in. Error: 7-Zip signalled an unknown error (code -1073741511)
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))' returned a non-zero code: 1
PS C:\Users\Administrator\example>
There have been a few issues from TLS changes to changes to the microsoft base images that have caused me some problems with 7zip and choco over the last 3 weeks. I've got my base images working now by adding the following:
RUN $text = '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13 -bor [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Ssl3 -bor [Net.SecurityProtocolType]::Tls'; \
$text | Set-Content 'C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1';
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; \
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
powershell -Command refreshenv; \
cinst -y --allow-empty-checksums 7zip.install make nuget.commandline --no-progress;
However I am still experiencing some issue in other images with the reported error: "7-Zip signalled an unknown error (code -1073741511)", however no doubt they boil down to the same thing. Again, if I exec in to the running container, I am able to manually run choco and install 7zip and even access the "7z" commands. I tried committing the container once I made the changes, but still got this issue.
Docker requires win 10 pro because it needs some virtualization extensions (HyperV and Containers). Can these requirements be fulfilled on win 10 Home?
Yes, it can be done on Windows 10 Home (tried on win10Home v1809 27.01.2019)
Run in a command prompt as administrator:
Install Hyper-V:
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause
Install Containers:
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*containers*.mum >containers.txt
for /f %%i in ('findstr /i . containers.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del containers.txt
Dism /online /enable-feature /featurename:Containers -All /LimitAccess /ALL
pause
Edit registry keys:
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /f /v EditionID /t REG_SZ /d "Professional"
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /f /v ProductName /t REG_SZ /d "Windows 10 Pro"
Download and run official Docker Installer For Windows.
In my case the registry keys were restored after restart, but you could restore them manually:
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID /t REG_SZ /d "Core"
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName /t REG_SZ /d "Windows 10 Home"
There is now a better way to run Docker on Windows 10 Home edition.
The next version of Docker for Windows runs on WSL 2 and MS has made an exception for WSL 2, allowing it to use hyper-V even on Home editions of Windows 10.
My justification for calling this 'better' is that this is the future of Docker on Windows because Docker inc. feels that this is a considerably better solution, as they discuss in their announcements about this new version.
But if you want to take advantage of this solution now (pre-2019H2 Windows update) you will need to install an insiders edition of Windows in order to use the WSL 2 preview and then install the preview of the new Docker.
2020-07 Update
Windows 10, version 2004 is now GA so I thought I would add to this. The above still holds true, but here are some new resources...
https://arstechnica.com/gadgets/2020/06/whats-new-in-windows-10-build-2004/
And scroll down to 'Windows Subsystem for Linux, version 2' for a good short discussion.
And an updated link to the Docker install...
Install Docker Desktop Stable 2.3.0.2 (or later).
https://docs.docker.com/docker-for-windows/wsl/
This might help someone who cannot upgrade their system to pro or professional. Consider installing Docker Toolbox on Windows. For mac users: Docker Toolbox on Mac.
Check out difference Here
Legacy desktop solution. Docker Toolbox is for older Mac and Windows systems that do not meet the requirements of 'Docker Desktop for Mac' and 'Docker Toolbox on Windows'. We recommend updating to the newer applications, if possible.
As per documentation, the toolbox includes these Docker tools:
Docker Machine for running docker-machine commands
Docker Engine for running the docker commands
Docker Compose for running the docker-compose commands
Kitematic, the Docker GUI
a shell preconfigured for a Docker command-line environment
Oracle VirtualBox
If you want to use Docker directly within Windows, and you want to run Windows containers, there's still no official support. Docker Desktop won't allow it; it says "Windows Containers support requires a Windows 10 Pro or enterprise build >= 14372".
However, if you're interested in Linux containers, and you have WSL2 on your Windows 10 Home instance (which you'll have as of version 1903+), you don't need to install Docker Desktop.
(1) Setup a Linux instance via WSL2
Get into an elevated CLI prompt (CMD and PS both work fine):
Confirm you've got WSL2: wsl --status
Install Ubuntu: wsl --install
Same as wsl --install --distribution ubuntu
After you're forced to reboot, and you log back in, you'll get a specialized command prompt window that pops up. Setup you Linux user and password. (If you forget, you can do a wsl --user root followed by passwd {your-account-name} to fix it.)
Update: sudo apt update && sudo apt upgrade
Mine didn't have ifconfig: sudo apt install -y net-tools
If you want more info on how to control your instance(s), look at the Microsoft docs.
In general, getting "into" the default, Ubuntu instance within WSL is as easy as typing either "bash" or "ubuntu" from a regular CLI prompt. Though, I'd highly recommend installing "Windows Terminal" and using that instead.
(2) Install Docker
Open up a prompt inside your Linux instance. The general instructions are here, if you need more help. I used a Ubuntu instance.
Trust the docker repo's GPG key: curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo apt-key add -
Same idea as: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add their stable repo as a package source: echo "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/${ID} $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
Same idea as: echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update your local index: sudo apt update
Install docker!: sudo apt install -y docker-ce docker-ce-cli containerd.io
Add your account to the "docker" group: sudo usermod -aG docker $USER
Get that group change to be recognized:
Close all of your open sessions and wait ~10 seconds for the Linux instance to get shutdown automatically. Then open up a new session.
Close the window and force the instance to restart (from a Windows CLI prompt): wsl --terminate {distro-name} . Then open up a new session.
Start docker: sudo -b dockerd
Prove it's working: docker run --rm hello-world
Dockerd and services/auto-start concerns
WSL2 doesn't presently have a clean way to auto-start the dockerd daemon. There's a lot of workarounds on the 'Net. Some people start it via a Scheduled task that starts dockerd via wsl. Some people start it via a smart chunk of code in either .profile or .bashrc. Soon, there's supposed to be a officially supported approach via the "[boot]" section of the /etc/wsl.conf file, but it still doesn't appear to have landed in Windows 10 20H2 as it was suggested it would.
UPDATE 2021-11-25: I decided on adding this to my .profile (copied from here). It goes around sudo.
if service docker status 2>&1 | grep -q "is not running"; then
wsl.exe -d "${WSL_DISTRO_NAME}" -u root -e /usr/sbin/service docker start > /dev/null 2>&1
fi
Interactions with the Windows host
From a Linux instance into Windows, there's mount points: /mnt/{windows-drive-letter}/...
From Windows into a Linux instance, there's a magic "share": \\wsl$\{linux-instance-name}\...
More info on how file permissions work when crossing OS boundaries.