maboloshi / Recordum

沙漠之子's 微博客
https://maboloshi.github.io/Recordum
2 stars 0 forks source link

ArchWSL下安装使用docker #7

Open maboloshi opened 4 years ago

maboloshi commented 4 years ago
pacman -S docker

ArchWSL下无法使用systemctl运行docker daemon

运行systemctl start docker 提示:

System has not been booted with systemd as init system (PID 1). Can't operate.

解决方法 https://github.com/yuk7/ArchWSL/issues/20#issuecomment-525916104

pacman -S python
# 安装 systemctl 替换版本
mv /usr/bin/systemctl /usr/bin/systemctl.old
curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > /usr/bin/systemctl
chmod +x /usr/bin/systemctl
systemctl enable docker
systemctl status docker
docker.service - Docker Application Container Engine 
Loaded: loaded (/usr/lib/systemd/system/docker.service, enabled)
Active: failed (failed)

激活失败 待解决

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?`
stupid-yu commented 3 years ago

[subsystemctl](GitHub - sorah/subsystemctl: Utility to run systemd in WSL2 with a Linux namespace) may help u.

# step 1
wsl -u root -- subsystemctl start

# step 2
sudo pacman -S docker

# step 3
sudo subsystemctl start
sudo subsystemctl exec sudo systemctl start docker
sudo subsystemctl exec sudo systemctl enable docker
stupid-yu commented 3 years ago

https://wsldl-pg.github.io/ArchW-docs/locale/zh-CN/Known-issues/#systemd