Installing Docker on windows 10 Home, can it be done? - windows

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.

Related

How to use docker in windows 10?

I am trying to use docker on my windows, but kept getting the docker: error during connection: This error may indicate that the docker daemon is not working. I have used all the solutions described on the Internet, but so far I have not been able to solve my problem.
For example, I applied all the answers with good evaluation of this one error during connection: This error may indicate that the docker daemon is not working.
Some of the things I have done:
Launch command: & 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
I have already uninstalled and installed docker again, using the installer as administrator.
I have changed the initialization type of the docker desktop service to as Automatic (Delayed).
PS C:\Users\diego\Stuffs\RiseIT\getting-started> & 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
PS C:\Users\diego\Stuffs\RiseIT\getting-started> docker run -d -p 80:80 docker/getting-started
docker: error during connect: This error may indicate that the docker daemon is not running.: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/create": open //./pipe/docker_engine: The system cannot find the file specified.
See 'docker run --help'.
I was having the same problem, in my case, I had forgotten to Enable the WSL 2 feature on Windows.
You can enable it using the official tutorial https://docs.microsoft.com/en-us/windows/wsl/install-win10.
Or if you prefer you can follow these steps:
1 . (PowerShell Admin): dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
2 . (PowerShell Admin):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
3 . RESTART THE COMPUTER
4 . (Download the Linux kernel update package):
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi>
5 . (PowerShell Admin): wsl --set-default-version 2
6 . (Install o docker): Tutorial: https://docs.docker.com/docker-for-windows/install/

Docker is not running when run curl command to create new laravel project

I just start learning laravel, and follow the tutorial from https://laravel.com/docs/8.x/installation "Getting started on Windows" .
I manage to install Docker Desktop and COnfigured to use WSL2 Backend.
When I run the command curl -s https://laravel.build/example-app | bash to create laravel application directory from cmd, this warning come out Docker is not running.
I run curl using command prompt. (cmd).
Update:
So, I run the command in Windows Terminal:.
PS E:\Play> curl -s https://laravel.build/example-app | bash
Here is the response I get:
cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri:
Any Idea what to do?
Try to explicitly enable integration with your distro in Docker settings:
After that relaunch your WSL2 terminal & try again. That should help.
You can also open https://laravel.build/example-app in a browser & check what commands the script is running: and run them manually to check the output for any errors.
For those who are using Ubuntu or Debian can check this guide out on how to install and configure Docker.
sudo snap install docker
sudo usermod -aG docker $(whoami)
sudo chmod 666 /var/run/docker.sock
You need to install a linux distro, and then in Windows Terminal create a new tab for the linux distro and run the command there, not in a windows powershell tab.
Make sure that you are running curl command on your distro. Use Windows Terminal app and open a new tab as WSL2 (your distro).
sudo chmod 666 /var/run/docker.sock
I guess you are using ubuntu or debian.
chmod will do the trick here.

Installing Ghostscript in Docker Windows image returned a non-zero code: 1

Dev environment: Windows Server 2019
Docker version: 19.03.5
The official Ghostscript documentation says this about installing on Windows:
4.1 Installing
To install Ghostscript on Windows, you should run the installer executable.
The installer is NSIS-based (see also Release.htm) and supports a few standard NSIS options: /NCRC disables the CRC check, /S runs the installer or uninstaller silently, /D sets the default installation directory (It must be the last parameter used in the command line and must not contain any quotes, even if the path contains spaces. Only absolute paths are supported).
Following this documentation, I put this in my Dockerfile:
FROM jenkins/agent:jdk8-nanoserver-1809
WORKDIR /tmp
ADD https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/gs952w64.exe .
RUN C:\tmp\gs952w64.exe /S
This is the output of docker build:
Sending build context to Docker daemon 5.632kB
Step 1/4 : FROM jenkins/agent:jdk8-nanoserver-1809
---> 026ce64bdabf
Step 2/4 : WORKDIR /tmp
---> Using cache
---> fd854f6da0a9
Step 3/4 : ADD https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/gs952w64.exe .
Downloading [==================================================>] 27.64MB/27.64MB
---> Using cache
---> 259453368869
Step 4/4 : RUN C:\tmp\gs952w64.exe /S
---> Running in c86c8393a4fa
The command 'pwsh.exe -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; C:\tmp\gs952w64.exe /S' returned a non-zero code: 1
Which means that Ghostscript wasn't installed.
Is this because I didn't specify an installation directory? I'm OK with the default directory.
Or should I forgo manual installation altogether and use some kind of package manager? I don't know how Windows does it nowadays, last time I used Windows we still had to install Trumpet Winsock to get online...
I solved it!
I made 2 changes:
Change base image from jenkins/agent:jdk8-nanoserver-1809 to jenkins/agent:jdk8-windowsservercore-1809 (next step won't work if you don't do this, Chocolatey is not suported on Windows Nano Server)
Install Chocolatey as package manager
FROM jenkins/agent:jdk8-windowsservercore-1809
ADD https://chocolatey.org/installchocolatey.cmd .
RUN .\installchocolatey.cmd
RUN choco install --yes ghostscript --version=9.24 ;\
choco install --yes imagemagick --version=7.0.10.14 ;\
Yes, two separate RUN commands. You must do this, because the Windows shell needs to be restarted to be able to find Chocolatey. I found this out the hard way, but the Chocolatey installer also says it at the end.

How to install Tomcat in Docker Windows Server Container?

On my windows server 2016 tp5 virtual machine, I would like to create a simple native windows based docker example without virtualbox.
The example needs tomcat for windows and since this windows server 2016 docker container uses a shared windows kernel, installing tomcat should be straight forward, alas! Using the following powershell docker build command stops with non-zero code: 255
Dockerfile in c:\build:
FROM microsoft/windowsservercore
RUN powershell -Command wget -Uri mirror.klaus-uwe.me/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70-windows-x64.zip -OutFile "$env:TEMP\tomcat-7.0.70.zip"
Admin-powershell:
docker build c:\build
Result:
---> Running in 317a3572890e
The command 'cmd /S /C powershell -Command wget -Uri mirror.klaus-uwe.me/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomca
t-7.0.70-windows-x64.zip -OutFile "$env:TEMP\tomcat-7.0.70.zip"' returned a non-zero code: 255
Although the zip file has been downloaded in my users temp dir.
Can anybody tell me, how a native windows tomcat installation should look like, as I am not really deep in this stuff.
As mentioned here:
The error code "255" usually means that it is not able to find the file you are asking it to execute
So try and test with the full path and name of the binary(ies) involved in your RUN command line (like powershell)
But test also a simpler case:
RUN dir c:\Users\
This has been recently reported as failing with the same exit code 255, which would mean the latest docker on Windows Server 2016 Technical Preview 5 has a bug.

Running docker shell on Windows

I've just installed Docker toolbox 1.9.1 (only docker itself plus Kitematic as I already have both VirtualBox and Git for Windows installed). Clicking on Docker Quickstart Terminal icon wasn't working so I had to associate it with C:\Program Files (x86)\Git\bin\bash.exe as suggested. Now it starts fine but I'm unable to run docker command:
Kitematic works just fine but I need the shell. How do I fix it?
Check where docker-machine.exe has been installed (or copy the latest released one in your %PATH%) and use that, instead of the quickstart.
From a regular CMD session:
# find the name of the machine created.
docker-machine ls
docker-machine env --shell cmd <nameOfTheMachine>
docker-machine ssh <nameOfTheMachine>
The shell you are after is the one provided by the Linux TinyCore boot2docker.iso image managed by VirtualBox, not the git-bash installed on your Windows host.
Here is an alternative option. Create the following docker.cmd batch:
cd "%ProgramFiles%\Docker Toolbox"
"%ProgramFiles(x86)%\Git\bin\bash.exe" --login -i "%ProgramFiles%\Docker Toolbox\start.sh"
Now you need to start the default VM in your Oracle VirtualBox Manager (created automatically when you installed Docker for Windows):
and then the batch:

Resources