This post is a serial of update steps (2024) to install Windows Subsystem for Linux (WSL) v2 including deploying Docker service on it at the end.
Table of Contents
Requirements
First ensure you have latest Windows updates installed. You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.
Hyper-V
Also ensure Hyper-V is enabled under Windows features (to open this dialog press WINDOWS key and type Turn Windows features on or off):
Windows Terminal
Optionally install Windows Terminal APP via Windows store:
WSL installation
Now open the terminal an use wsl
command to be installed via:
wsl --install
When asked allow the pop-up message to scale up privileges (it could be requested several times):
Ubuntu will be installed by default (check options of previous command if you prefer other distribution):
After installation you will need to reboot Windows:
After rebooting Windows, a terminal window will appear automatically to finish Ubuntu installation:
It will take a while to install, when it finishes press any key to close the window.
If when it finishes you receive a message that virtualization is not enabled in the BIOS, please check it rebooting Windows and entering your BIOS settings, typically under CPU settings:
Now you can open Terminal APP and under the triangle of the + symbol select Ubuntu (you could change which one to open by default in Settings menu):
First time it will need to finish Ubuntu installation:
Once installed you will need to fill username & password (twice):
Ubuntu preparation
Ubuntu updates
First thing is to update Ubuntu with:
sudo apt update
sudo apt dist-upgrade
Systemd
Then we need to ensure systemd is enabled in wsl settings, edit the file /etc/wsl.conf
and check these lines are present:
[boot]
systemd=true
Docker
Now, we install docker.io
and add your user to docker
group to be able to run docker commands with your user (not requiring root
user):
sudo apt install docker.io
sudo adduser emilio docker
Close the terminal and open it again to apply permissions changes, after this you can check the installed version and run a hello-world container:
$ docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1
$ docker run -it --rm hello-world
All is done! 🙂