Windows 10 (20H1 / 2004 / Mai 2020 Update) with WSL2 is out, this guide should be obsolete now.
Upgrading an existing WSL1 setup to WSL2
Note, this is only needed on Windows 10 Home and WSL1. If you have Windows 10 Pro, you can run Docker for Windows (https://docs.docker.com/docker-for-windows).
After completing this guide, you will have a Windows 10 Home running the docker deamon via Docker Toolbox / VirtualBox. The WSL guest OS will connect to this docker deamon, and will have the Windows OS filesystem mapped as C:\
-> /c/
instead of C:\
-> /mnt/c/
, which will fix path translation between docker deamon on Windows and docker client in WSL guest OS.
Install Docker Toolbox on Windows 10: (https://github.com/docker/toolbox/releases)
Enable WSL and make sure Hyper-V is disabled via Command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
bcdedit /set hypervisorlaunchtype off
Install an WSL guest OS via Microsoft Store:
- Ubuntu 18.04 LTS (https://www.microsoft.com/store/apps/9N9TNGVNDL3Q)
- Others linked here: https://docs.microsoft.com/de-de/windows/wsl/install-win10
#!/bin/bash
WINDOWS_USER_DIRECTORY=/c/Users/MyUserName
DOCKER_HOST=192.168.99.100:2376
PATH_TO_ID_RSA="${WINDOWS_USER_DIRECTORY}/.ssh/id_rsa"
echo "Configuring WSL automount to root (needs Windows restart to work)"
sudo bash -c 'cat << EOF > /etc/wsl.conf
[automount]
root = /
options = "metadata"
EOF'
echo "Installing docker, docker-compose and utils for docker login"
sudo apt-get -y update \
&& apt-get -y install \
docker.io \
docker-compose \
gnupg2 pass \
&& apt-get -y autoremove
echo "Exporting environments"
echo "export DOCKER_CERT_PATH='${WINDOWS_USER_DIRECTORY}/.docker/machine/certs'" >> ~/.bashrc
echo "export DOCKER_HOST=tcp://${DOCKER_HOST}" >> ~/.bashrc
echo "export DOCKER_TLS_VERIFY=1" >> ~/.bashrc
echo "export COMPOSE_TLS_VERSION=TLSv1_2" >> ~/.bashrc
source ~/.bashrc
echo "Testing docker setup"
docker info
docker-compose ps
echo "Adding id_rsa from host user"
eval $(ssh-agent)
ssh-add ${PATH_TO_ID_RSA}
- https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
- https://docs.microsoft.com/de-de/windows/wsl/install-win10
- https://blog.zeddba.com/2017/09/25/disabling-microsofts-hyper-v-to-use-oracles-virtualbox/
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
You can remove Docker Toolbox (including Oracle VirtualBox) now from your system.
- Kernel: https://docs.microsoft.com/de-de/windows/wsl/wsl2-kernel
- Docker Desktop: https://docs.docker.com/docker-for-windows
wsl --set-default-version 2
wsl --set-version Ubuntu-18.04 2
great! this guide for wsl1 saved me!
wsl2 does not work on corporate proxy.