I am trying to install docker on Windows Subsystem for Linux (WSL) 2 (running on Windows Home build 19033.1). I installed wsl2 as per the instructions at https://learn.microsoft.com/en-us/windows/wsl/wsl2-install and installed debian from the Windows Store, which is debian 10 (buster). It is running on wsl 2 as proven by this:
wsl -l -v
NAME STATE VERSION
* Debian Running 2$ cat /etc/os-release
PRETTY_NAME=”Debian GNU/Linux 10 (buster)”
NAME=”Debian GNU/Linux”
VERSION_ID=”10″
VERSION=”10 (buster)”
VERSION_CODENAME=buster
ID=debian
HOME_URL=”https://www.debian.org/”
SUPPORT_URL=”https://www.debian.org/support”
BUG_REPORT_URL=”https://bugs.debian.org/”
I followed instructions at https://linuxconfig.org/how-to-install-docker-on-debian-10-buster-linux to install docker:
sudo apt install docker.io
sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Looked to see if docker was running:
sudo service docker status
[FAIL] Docker is not running … failed!
So I try to restart docker daemon:
$ sudo service docker restart
grep: /etc/fstab: No such file or directory
[ ok ] Starting Docker: docker.
Found another article on SO saying I could solve that by issuing:
sudo touch /etc/fstab
and that seemed to work (grep error is no longer appearing):
$ sudo service docker restart
[ ok ] Starting Docker: docker.
But I’m still getting the same problem:
$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
I looked at the docker log and its full of errors:
$ cat /var/log/docker.log | grep -i error
time="2019-11-28T21:48:51.725383200Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.btrfs" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"
time="2019-11-28T21:48:51.726777600Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.aufs" error="modprobe aufs failed: "modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.84-microsoft-standard/modules.dep.bin'\nmodprobe: FATAL: Module aufs not found in directory /lib/modules/4.19.84-microsoft-standard\n": exit status 1"
time="2019-11-28T21:48:51.726982500Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.zfs" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter"
time="2019-11-28T21:48:51.727010800Z" level=warning msg="could not use snapshotter aufs in metadata plugin" error="modprobe aufs failed: "modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.84-microsoft-standard/modules.dep.bin'\nmodprobe: FATAL: Module aufs not found in directory /lib/modules/4.19.84-microsoft-standard\n": exit status 1"
time="2019-11-28T21:48:51.727022700Z" level=warning msg="could not use snapshotter zfs in metadata plugin" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter"
time="2019-11-28T21:48:51.727031100Z" level=warning msg="could not use snapshotter btrfs in metadata plugin" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"
time="2019-11-28T21:48:51.744791900Z" level=warning msg="Running modprobe nf_nat failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.84-microsoft-standard/modules.dep.bin'nmodprobe: WARNING: Module nf_nat not found in directory /lib/modules/4.19.84-microsoft-standard`, error: exit status 1"
time="2019-11-28T21:48:51.746095200Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.84-microsoft-standard/modules.dep.bin'nmodprobe: WARNING: Module xt_conntrack not found in directory /lib/modules/4.19.84-microsoft-standard`, error: exit status 1"
time="2019-11-28T21:48:51.768996800Z" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
time="2019-11-28T21:48:51.769171500Z" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libcontainerd namespace=plugins.moby
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables --wait -t nat -N DOCKER: iptables v1.8.2 (nf_tables): CHAIN_ADD failed (No such file or directory): chain PREROUTING
Bit lost as to what the problem is here. Hoping someone can advise?
I followed the excellent advice from @s-x-tan below who recommended following instructions at https://kind.sigs.k8s.io/docs/user/using-wsl2/#updating-kernel. Those instructions say to issue:
# This assumes Ubuntu or Debian, a different step may be needed for RPM based distributions
sudo apt install build-essential flex bison libssl-dev libelf-dev
git clone --depth 1 https://github.com/microsoft/WSL2-Linux-Kernel.git
cd WSL2-Linux-Kernel
make -j4 KCONFIG_CONFIG=Microsoft/config-wsl
mkdir /mnt/c/linuxtemp
cp arch/x86_x64/boot/bzImage /mnt/c/linuxtemp/
Unfortunately the commands don’t produce the same dir strucuture that that cp
command is expecting. I do not have arch/x86_x64/
dir. I do have an arch/x86
dir but that doesn’t contain boot/bzImage
:
jamiet@DESKTOP-GA45TGH:/mnt/c/Users/jamie/git/github/microsoft/WSL2-Linux-Kernel$ ls arch/x86/boot/
a20.c code16gcc.h cpuflags.h install.sh pm.c string.h video.c
apm.c compressed ctype.h main.c pmjump.S tools video.h
bioscall.S copy.S early_serial_console.c Makefile printf.c tty.c video-mode.c
bitops.h cpu.c edd.c memory.c regs.c version.c video-vesa.c
boot.h cpucheck.c genimage.sh mkcpustr.c setup.ld vesa.h video-vga.c
cmdline.c cpuflags.c header.S mtools.conf.in string.c video-bios.c
I followed the exact instructions so can only guess that the repo has changed since https://kind.sigs.k8s.io/docs/user/using-wsl2/#updating-kernel was written. In case it helps, here are the dirs in arch
:
jamiet@DESKTOP-GA45TGH:/mnt/c/Users/jamie/git/github/microsoft/WSL2-Linux-Kernel$ ls arch/
alpha arm c6x hexagon Kconfig microblaze nds32 openrisc powerpc s390 sparc unicore32 xtensa
arc arm64 h8300 ia64 m68k mips nios2 parisc riscv sh um x86
Still hoping for some clarity from someone.
2
Answers
I’m having the same issue, because Debian doesn’t have the modules of 4.19.84-microsoft-standard kernel installed. Unfortunately Microsoft doesn’t provide pre-built lib/modules for this kernel, you have to build the kernel using the source code from https://github.com/microsoft/WSL2-Linux-Kernel.
I tried kernel 4.9.0-11-amd64 extracted from Debian image as the custom kernel (in .wslconfig) but WSL2 couldn’t boot it up. So there is no other way around.
Here are the instructions:
https://kind.sigs.k8s.io/docs/user/using-wsl2/#updating-kernel
After built the kernel, run sudo make modules_install, then run docker:
*docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.*
Posting here in case anyone one else has this issue as I just did. It seems to be the same problem as https://superuser.com/questions/1468316/which-kernel-moduules-are-really-needed-for-docker-installation
As per that answer, after running:
I was able to start start the docker service.