Skip to content

Instantly share code, notes, and snippets.

Last active January 10, 2023 20:36
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ChristophShyper/a4457ecb64db6d2fd11fe994bb614e13 to your computer and use it in GitHub Desktop.
Instruction how to set up WSL2 to work with Docker in Windows 10

On Windows 10 build 18917 or higher

Win / Enable WSL and VMP


Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Win / Set WSL 2 as default


wsl --set-default-version 2

Win / Install Linux distro from Microsoft Store

For example Ubuntu 18.04 LTS

Win / Optional: Install X11 server

For example VcXsrv.

WSL / Optional: Prepare for X11 on Windows

Add to ~/.bashrc (provide IP of your Windows host):

export DISPLAY=

Win / Install Docker Desktop Edge

Download version or search for latest.
Enable Enable the experimental WSL 2 based engine on General tab.
Enable your WSL distro on Resources tab.

WSL / Install Docker


sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo gpasswd -a $USER docker
sudo mkdir /sys/fs/cgroup/systemd
sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
sudo service docker start

WSL / Verify


docker info
docker run hello-world
Copy link

richeney commented May 6, 2020

Good instructions. One thing - the

curl -fsSL | sudo apt-key add –

line errored on my Ubuntu 18.04 when I copy and paste it in, even from the raw It looks like the hyphen at the end has some odd control characters around it? (Is it an em dash or en dash rather than a hyphen?)

/git $ echo 'curl -fsSL | sudo apt-key add –' | cat -tev
curl -fsSL | sudo apt-key add M-bM-^@M-^S$

Copy link

Thanks for reporting it. I made it on Windows so it must have change characters and didn't notice that. Fixed now.

Copy link

jfmatth commented Apr 10, 2021

I gave up on Docker and went to podman, much much simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment