我正在尝试在Windows Subsystem for Linux(WSL)2上安装docker(在Windows Home build 19033.1上运行)。我按照https://docs.microsoft.com/en-us/windows/wsl/wsl2-install上的说明安装了wsl2,并从Windows应用商店中安装了debian,即debian 10(破坏者)。事实证明,它正在wsl 2上运行:
wsl -l -v
名称状态版本
* Debian Running 2$ cat / etc / os-release
PRETTY_NAME =“ Debian GNU / Linux 10(buster)”
NAME =“ Debian GNU / Linux”
VERSION_ID =“ 10”
VERSION =“ 10(破坏者)”
VERSION_CODENAME =破坏者
ID = debian
HOME_URL =“ https://www.debian.org/”
SUPPORT_URL =“ https://www.debian.org/support”
BUG_REPORT_URL =“ https://bugs.debian.org/”
我按照https://linuxconfig.org/how-to-install-docker-on-debian-10-buster-linux上的说明安装了docker:
sudo apt安装docker.io
sudo docker运行hello-world
docker:无法通过unix:///var/run/docker.sock连接到Docker守护程序。 Docker守护程序正在运行吗?。
查看docker是否正在运行:
sudo服务docker状态
[失败] Docker未运行...失败!
所以我尝试重启docker daemon:
$ sudo服务docker restart
grep:/ etc / fstab:没有这样的文件或目录
[确定]启动Docker:docker。
找到另一个article on SO,说我可以通过发出以下命令来解决该问题:
sudo touch / etc / fstab
似乎有效(不再出现grep错误):
$ sudo服务docker restart
[确定]启动Docker:Docker。
但是我仍然遇到相同的问题:
$ sudo docker运行hello-world
docker:无法通过unix:///var/run/docker.sock连接到Docker守护程序。 Docker守护程序正在运行吗?。
我查看了docker日志及其全部错误:
$ 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
关于这里的问题,有些失落。希望有人可以提供建议?
我遵循了@ s-x-tan的出色建议,他在https://kind.sigs.k8s.io/docs/user/using-wsl2/#updating-kernel上推荐了以下说明。这些说明说要发出:
# 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/
不幸的是,这些命令产生的目录结构与cp
命令所期望的目录结构不同。我没有arch/x86_x64/
目录。我确实有一个arch/x86
目录,但其中不包含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
我遵循了确切的说明,因此只能猜测自编写https://kind.sigs.k8s.io/docs/user/using-wsl2/#updating-kernel以来,回购已更改。如果有帮助,请参见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
仍然希望有人能提供一些澄清。
答案 0 :(得分:2)
在这里发布,以防其他人遇到我刚刚遇到的这个问题。看来和https://superuser.com/questions/1468316/which-kernel-moduules-are-really-needed-for-docker-installation
一样根据该答案,运行后:
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
我能够启动docker服务。
答案 1 :(得分:1)
我遇到了同样的问题,因为Debian没有安装 4.19.84-microsoft-standard 内核的模块。不幸的是,Microsoft没有为此内核提供预构建的lib /模块,您必须使用https://github.com/microsoft/WSL2-Linux-Kernel中的源代码来构建内核。
我尝试从Debian映像提取的内核4.9.0-11-amd64作为自定义内核(在.wslconfig中),但WSL2无法启动它。因此,别无选择。
以下是说明: https://kind.sigs.k8s.io/docs/user/using-wsl2/#updating-kernel
构建内核后,运行 sudo make modules_install ,然后运行docker:
* docker运行hello-world
您好,Docker!
此消息表明您的安装似乎正常工作。*