简体   繁体   中英

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

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 :

  1. 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
  2. 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
  3. 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"
  4. Download and run official Docker Installer For Windows.

  5. 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".

Windows Containers 支持需要 Windows 10 专业版或企业版 >= 14372

However, if you're interested in Linux containers, and you have WSL2 on your Windows 10 Home instance (which you'll haveas 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):

  1. Confirm you've got WSL2: wsl --status
  2. Install Ubuntu: wsl --install
    • Same as wsl --install --distribution ubuntu
  3. 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.)
  4. Update: sudo apt update && sudo apt upgrade
  5. 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.

  1. Trust the docker repo's GPG key: curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo apt-key add - 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 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  2. 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 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 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
  3. Update your local index: sudo apt update
  4. Install docker!: sudo apt install -y docker-ce docker-ce-cli containerd.io
  5. Add your account to the "docker" group: sudo usermod -aG docker $USER
  6. 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.
  7. Start docker: sudo -b dockerd
  8. 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 . I'm probably going to go the .bashrc route, but for now, I just manually start it.

Interactions with the Windows host

  • From a Linux instance into Windows, there's read-only mount points: /mnt/{windows-drive-letter}/...
  • From Windows into a Linux instance, there's a magic "share": \\\\wsl$\\{linux-instance-name}\\...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM