Do you want to install Docker on a brand new WSL2 19.10 distro? Make it available on “boot” via SystemD?

Now it’s possible and for the first time, it will be explained as a “fast track”. A new series of mini-blogs with (very) few chat and lots of hands-on.


As “usual”, the prerequisites will be:

  1. Windows 10 insider fast (current: 19008)
  2. WSL2 feature installed
  3. Ubuntu 19.10 WSL rootfs

Ermine has a new home

The first step will be to create a new WSL distro.

In this example, the server version will be the one chosen:

PS> mkdir c:\mywsldistros
PS> wget -OutFile ermine-server.tar.gz
PS> wsl.exe --import ermine c:\mywsldistros\ermine c:\mywsldistros\ermine-server.tar.gz --version 2
PS> wsl.exe -d ermine
# cat /etc/os-release

Adding a new WSL2 Ubuntu 19.10 distro

System configuration

Let’s configure the system by adding our user and systemD:

# apt update && apt upgrade -y
# useradd -m -s /bin/bash ermine
# apt install -yqq daemonize dbus-user-session fontconfig sudo vim
# vi /usr/sbin/start-systemd-namespace
# vi /usr/sbin/enter-systemd-namespace
# chmod +x /usr/sbin/enter-systemd-namespace
# vi /etc/bash.bashrc
# visudo
# vi /etc/wsl.conf
# exit
PS> wsl.exe --terminate ermine
PS> wsl.exe -d ermine
$> ps -ef

First update

Adding a user and the SystemD required packages

Configuring SystemD

Restart the WSL2 distro

Displaying the SystemD processes

The Whale is visiting

As the Docker package does not exist yet for Ubuntu 19.10 (mind the blog release date), the steps below are the “manual” approach:

$> wget
$> wget
$ sudo tar -xzf docker-19.03.4.tgz -C /usr/bin --strip-components=1
$ sudo tar -xzf containerd-1.3.0.linux-amd64.tar.gz -C /usr/bin --strip-components=1
$ sudo wget -O /etc/systemd/system/docker.service
$ sudo wget -O /etc/systemd/system/docker.socket
$ sudo groupadd docker
$ sudo usermod -aG docker ermine
$ sudo systemctl enable docker.socket
$ sudo systemctl enable docker.service
$ sudo systemctl start docker.socket
$ sudo systemctl start docker.service
$ exit
PS> wsl.exe --terminate ermine
PS> wsl.exe -d ermine
$ docker version

Downloading Docker and Containerd binaries

Downloading the Docker SystemD files

Extracting Docker and Containerd binaries to /usr/bin

Starting the Docker SystemD services

Running the first container


Ok I promised right, no chat -> pure hands-on.

Still, the (huge) learning from this blog post is that Docker really helps getting things started fast. I mean, in a normal case, a simple package install would suffice and everything would have been good to go.

I hope this shorter format will please you, as I might do some more between two bigger blog posts. This will help me adding a bit more context to the “discovery tweets” I do regularly.

>>> Nunix out <<<

Bonus 1: a Snap and Microk8s appears

Now that Docker is up and running, nowadays next step would be to add a Kubernetes context.

In this first bonus, we will add MicroK8s. To make it easy, let’s follow the official guide:

$ sudo snap install microk8s --classic
$ microk8s.status --wait-ready
$ sudo snap alias microk8s.kubectl mk
$ mk cluster-info
$ mk get nodes
$ mk get services

Installing Microk8s

But wait! There’s more

The goal is always to have a complete and integrated environment. To achieve that, some additional steps need to be performed.

As described in the guide, couple addons should be installed

$ microk8s.enable dns dashboard
$ mk cluster-info

Adding addons and saving configuration

Finally, let’s had our cluster as the Docker context endpoint:

$ docker context ls
$ mk config view --raw > $HOME/.kube/config
$ docker context ls

Adding Microk8s endpoint to Docker context