Setting Up Docker on WSL2 with Ubuntu 24.04: An Easy Guide

Updated on
Setting Up Docker on WSL2 with Ubuntu 24.04: An Easy Guide

Step1. activate WSL2

https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-1---enable-the-windows-subsystem-for-linux

Step2. update WSL2

wsl --update

Step3. install ubuntu

# check available distributions
wsl --list --online

# install 24.04
wsl --install -d Ubuntu-24.04

Step4. install curl and packages

sudo apt -y update
sudo apt -y install curl
sudo apt -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Step5. install docker

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# check docker version
docker -v

Step6. add your account to docker group

sudo groupadd docker
sudo usermod -aG docker $USER

Optional

change memory size

New-Item ~/.wslconfig

add memory info to .wslconfig

[wsl2]
memory=32GB

shutdown

wsl --shutdown