Skip to content

Instantly share code, notes, and snippets.

@11iq
Created July 12, 2024 10:50
Show Gist options
  • Save 11iq/c6cdd3b50e912e484e94dc50c5a7fb5d to your computer and use it in GitHub Desktop.
Save 11iq/c6cdd3b50e912e484e94dc50c5a7fb5d to your computer and use it in GitHub Desktop.
Install docker in Debian 12/WSL2
1. Update wsl

PS> wsl --update

2. Check wsl version (if "--version" is not available, then your wsl vesion is not up to date)

PS> wsl --version

WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22621.3296
3. Install Debian

PS:> wsl --install -d debian

4. Install curl

$ sudo apt update && sudo apt -y install curl

5. Enable systemd

$ echo -e "[boot]\nsystemd=true" | sudo tee -a /etc/wsl.conf

6. Shutdown debian from inside

$ wsl.exe --shutdown

7. Start debian

PS> wsl -d debian

8. Install docker (script will add docker repo and install these docker packages: docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin)

$ curl https://get.docker.com | sh

9. Check docker service

$ sudo systemctl status docker

10. Add current user to docker group

$ sudo usermod -aG docker $USER

11. Use new group without logging out

$ exec sg docker "newgrp `id -gn`"

12. Test docker with hello-world

$ docker run hello-world

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