Last active
          June 22, 2025 20:51 
        
      
    install docker in Debian 11/WSL2 without Docker Desktop
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # install docker in Debian 11/WSL2 | |
| # uses systemd-genie since docker requires systemd but it's not available for WSL | |
| # this is an alternative to Docker Desktop | |
| # prerequisites | |
| sudo apt-get update | |
| sudo apt-get dist-upgrade | |
| sudo apt-get install ca-certificates curl wget gnupg lsb-release apt-transport-https | |
| # systemd-genie requires dotnet runtime, add Microsoft repo | |
| wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb | |
| sudo dpkg -i /tmp/packages-microsoft-prod.deb | |
| rm /tmp/packages-microsoft-prod.deb | |
| # add systemd-genie repo | |
| sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg | |
| sudo chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg | |
| echo -e "deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main | |
| deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/wsl-transdebian.list > /dev/null | |
| # install systemd-genie | |
| sudo apt-get update | |
| sudo apt-get install systemd-genie | |
| # install docker | |
| curl https://get.docker.com | sh | |
| # allow docker commands to be used without sudo | |
| sudo usermod -aG docker $USER | |
| # nftables is the default implementation of iptables on Debian but requires linux kernel 5.8+ which is not available on WSL2 | |
| # https://patrickwu.space/2021/03/09/wsl-solution-to-native-docker-daemon-not-starting/ | |
| sudo update-alternatives --set iptables /usr/sbin/iptables-legacy | |
| # install docker-compose 1.x | |
| sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
| sudo chmod +x /usr/local/bin/docker-compose | |
| # run systemd-genie when wsl starts | |
| echo "genie -i" >> ~/.bashrc | |
| # restart wsl | |
| exit | |
| wsl --shutdown | |
| wsl | |
| docker run hello-world | 
Thank you! Very useful
Guess you don't need to switch to iptables-legacy anymore
Just tested without and confirmed,  the kernel is 5.15 now
Apparently Docker is now detecting WSL installations and skipping/aborting the script.
# Executing docker install script, commit: c84dd77e3bbab4434b0ca76ca40597084ef228fe
WSL DETECTED: We recommend using Docker Desktop for Windows.
Please get Docker Desktop from https://www.docker.com/products/docker-desktop/
You may press Ctrl+C now to abort this script.
+ sleep 20
The script would refuse to run even after waiting 20 seconds.
I only needed:
sudo sh get-docker.sh```
To get this running on Debian 12 (bookworm) on WSL2.
There is a docker.io package on debian. I installed that instead of script you shared, worked fine. What would be the difference?
I did that because shell script was failing with timeouts.
Ah sorry for the late reply, I was having issues with installing it on windows running on arm using wsl2 for debian
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Just a note: You don't need
systemd-genieanymore. You can boot systemd automatically in WSL2Just create an
/etc/wsl.confand set it to start on boot,sudo touch wsl.conf && sudo echo -e "[boot]\nsystemd=true\n" >| /etc/wsl.conf && sudo shutdown -r nowafter reboot
sudo systemctl list-unit-files --type=service