WSL上のFedoraでDockerを使ってみたい(残念ながら、今回も失敗)

WSL上のFedoraでDockerを使ってみたい。

$ docker run hello-world
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

残念ながら、systemdがPID 1で動作していないので、docker runが動かない。
対処方法は、以下のURLでgenieを使えば良いことが判明。
https://www.tomoyan.net/windows/wsl

$ sudo dnf install git
$ cd ~
$ git clone https://github.com/arkane-systems/genie.git
$ cd genie

ここでMakefileを見ると、
make package-fedora
すればよさそうだとわかる。しかし、ビルド環境がないから、そちらを先にinstallする。
$ sudo dnf install make
$ sudo dnf install rpmdevtools
このrpmdevtoolsってのは、

qiita.com

を参考にインストール。

$ make package-fedora
すると、また違うエラー
error: Failed build dependencies:
dotnet-sdk-5.0 is needed by genie-1.43-1.fc34.x86_64

依存性をインストール
$ sudo dnf install dotnet-sdk-5.0

$ make package-fedora
すると、さらに違うエラー
+ install -m 0755 -o root othersrc/scripts/map-user-runtime-dir.sh /home/xxxx/rpmbuild/BUILDROOT/genie-1.43-1.fc34.x86_64/usr/libexec/genie
install: cannot change ownership of '/home/xxxx/rpmbuild/BUILDROOT/genie-1.43-1.fc34.x86_64/usr/libexec/genie/map-user-runtime-dir.sh': Operation not permitted

これって、root権限が必要ってこと?面倒だな。
$ sudo make package-fedora
すると、またまた違うエラー
install -m 0644 -vp othersrc/usr-lib/binfmt.d/WSLInterop.conf' /root/rpmbuild/BUILDROOT/genie-1.43-1.fc34.x86_64/usr/lib/binfmt.d/
install: cannot stat 'othersrc/usr-lib/tmpfiles.d/genie-stub-resolv.conf /root/rpmbuild/BUILDROOT/genie-1.43-1.fc34.x86_64/usr/lib/tmpfiles.d/'$'\n''install -m 0644 -vp othersrc/usr-lib/binfmt.d/WSLInterop.conf': No such file or directory

$ ls othersrc/usr-lib/binfmt.d/
WSLInterop.conf
あるんだけど。
$ sudo ls /root/rpmbuild/BUILD/genie-1.43/othersrc/usr-lib/binfmt.d
WSLInterop.conf
こっちにもあるな。

 

どうやらgenie.specが腐っている感じ。

$ diff -uNr package/fedora/genie.spec.old package/fedora/genie.spec
--- package/fedora/genie.spec.old 2021-07-23 18:50:48.368428000 +0900
+++ package/fedora/genie.spec 2021-07-23 18:51:16.563295900 +0900
@@ -52,8 +52,8 @@
install -m 0644 -vp othersrc/lib-systemd-system/wslg-xwayland.service %{buildroot}%{_unitdir}
install -m 0644 -vp othersrc/lib-systemd-system/wslg-xwayland.socket %{buildroot}%{_unitdir}
install -m 0644 -vp othersrc/lib-systemd-system/user-runtime-dir@.service.d/override.conf %{buildroot}%{_unitdir}/user-runtime-dir@.service.d
-install -m 0644 -vp othersrc/usr-lib/tmpfiles.d/genie-stub-resolv.conf" %{buildroot}%{_exec_prefix}/lib/tmpfiles.d/
-install -m 0644 -vp othersrc/usr-lib/binfmt.d/WSLInterop.conf" %{buildroot}%{_exec_prefix}/lib/binfmt.d/
+install -m 0644 -vp othersrc/usr-lib/tmpfiles.d/genie-stub-resolv.conf %{buildroot}%{_exec_prefix}/lib/tmpfiles.d/
+install -m 0644 -vp othersrc/usr-lib/binfmt.d/WSLInterop.conf %{buildroot}%{_exec_prefix}/lib/binfmt.d/
ln -sf %{_libexecdir}/%{name}/%{name} %{buildroot}%{_bindir}/%{name}
ln -sf %{_libexecdir}/%{name}/80-genie-envar.sh %{buildroot}%{_exec_prefix}/lib/systemd/system-environment-generators/
ln -sf %{_libexecdir}/%{name}/80-genie-envar.sh %{buildroot}%{_exec_prefix}/lib/systemd/user-environment-generators/

 

もとに戻ってビルド
$ sudo make package-fedora
$ ls out/fedora/
genie-1.43-1.fc34.x86_64.rpm

無事に完成。
早速インストール。
$ sudo rpm -ivh out/fedora/genie-1.43-1.fc34.x86_64.rpm
error: Failed dependencies:
daemonize is needed by genie-1.43-1.fc34.x86_64
systemd-container is needed by genie-1.43-1.fc34.x86_64

 

依存関係の解決。

$ sudo dnf install daemonize systemd-container

再チャレンジ。
$ sudo rpm -ivh out/fedora/genie-1.43-1.fc34.x86_64.rpm


$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 8948 396 ? Ssl 17:15 0:00 /init
root 745 0.0 0.0 8948 232 tty1 Ss 17:49 0:00 /init

$ sudo genie -s
genie: systemd is not supported under WSL 1.

えっ? WSL 1環境だったのか?

 

ということで、古いPCではBIOSに仮想化がないのでダメっぽい。