Docker on Debian on WSL2

IAITS

Docker on Linux on WSL2 is an attractive alternative to Docker for Windows Desktop in an enterprise setting where licensing money are tight, so here's a quick rundown.

  1. Enable Windows Subsystem for Linux (and the Windows Virtualization Platform)
  2. Download and install the Kernel Update (https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi)
  3. Open Command Prompt / Powershell
    1. wsl.exe --set-default-version=2
    2. wsl.exe --install -D Debian (you'll be prompted to supply root username and password)

You should now have a Debian installation - you need to make sure it's the latest (Debian 11 / Bullseye  at the time of writing).

Open WSL (type wsl.exe in command prompt) and run the following commands

  1. sudo apt-get install lsb-release (supply root password)
  2. lsb_release -a

It should return something like 

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

If not, edit /etc/apt/sources.list and replace version name from "stretch" to "buster" or "buster" to "bullseye" (if you're on Debian 9 or 10 respectively), run "sudo apt update  && sudo apt upgrade && sudo apt full-upgrade"  (first 9-> 10, restart, then 10 -> 11)

When on Debian 11 on WSL2

Firstly, I need to mention that I ran into this issue when installing: docker service will not start on Debian on wsl2 · Discussion #4872 · microsoft/WSL · GitHub. To spare you the read, run "update-alternatives --set iptables /usr/sbin/iptables-legacy" and "update-alternatives --set iptables6 /usr/sbin/iptables6-legacy" before installing.

Otherwise follow the instructions here: Install Docker Engine on Debian | Docker Documentation - there's really no point in my copying the instructions here. Remember to check the Docker Engine post-installation steps | Docker Documentation, it contains the instructions to add your user to the docker-group and how to start docker automatically.

 

 

Comments are closed