win10+WSL安装LXD容器
在 Linux 上安装 LXD 的最简单方法是安装 snap 包,该包可用于不同的 Linux 发行版。
1. 首先安装snap包
$ sudo apt update
$ sudo apt install snapd
接下来安装snapd core
$ sudo snap install core
error: cannot communicate with server: Post "http://localhost/v2/snaps/core": dial unix /run/snapd.socket: connect: no such file or directory
为解决上面的报错要执行以下命令
$ sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
$ sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
$ exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
$ snap version
执行
$ sudo service snapd start
这里插一句 一开始使用的systemd命令
$ sudo systemctl snapd start
error: System has not been booted with systemd as init system (PID 1). Can't operate.
原因:您的Linux系统没有使用systemd。如果你在Windows里面用WSL使用Ubuntu,那么你的系统就会有SysV而不是systemd,当你运行systemctl命令时,你的系统就会抱怨。
如何解决’System has not been booted with systemd’错误?
答案很简单,就是不要使用systemctl命令,而是使用等同的sysvinit命令。相反,可以使用对应的sysvinit命令。
切回正题
执行过sudo service snapd start之后,需要安装core来获取最新版snapd
$ sudo snap install core
core 16-2.45.2 from Canonical✓ installed
为了测试系统,安装hello-world snap并保证正确运行
$ sudo snap install hello-world
hello-world 6.3 from Canonical✓ installed
$ hello-world
Hello World!
snap就已经装好了。
2. 接下来安装lxd容器
$ sudo snap install lxd
lxd 5.11-ad0b61e from Canonical✓ installed
至此,LXD就在WSL上安装好了。
参考网页
[1]: https://www.cnblogs.com/a5idc/p/13752839.html
[2]: https://github.com/microsoft/WSL/issues/5126