如何延迟 Docker (docker.service) 启动,直到 USB SSD 在 RPi 上准备就绪?

如何延迟 Docker (docker.service) 启动,直到 USB SSD 在 RPi 上准备就绪?

我已将 Docker 根移动到已安装的 USB SSD,但这似乎阻止了 Docker 在重新启动时启动:

root@rpi64:~# journalctl -u docker.service -b
-- Journal begins at Sat 2021-10-30 20:46:14 AWST, ends at Thu 2021-12-16 14:01:00 AWST. --
Dec 16 13:39:22 rpi64 systemd[1]: Starting Docker Application Container Engine...
Dec 16 13:39:25 rpi64 dockerd[1038]: time="2021-12-16T13:39:25.010377383+08:00" level=info msg="Starting up"
Dec 16 13:39:25 rpi64 dockerd[1038]: mkdir /var/lib/docker: file exists
Dec 16 13:39:25 rpi64 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Dec 16 13:39:25 rpi64 systemd[1]: docker.service: Failed with result 'exit-code'.
Dec 16 13:39:25 rpi64 systemd[1]: Failed to start Docker Application Container Engine.


root@rpi64:~# journalctl -u containerd -b
-- Journal begins at Sat 2021-10-30 20:46:14 AWST, ends at Thu 2021-12-16 14:03:45 AWST. --
Dec 16 13:39:20 rpi64 systemd[1]: Starting containerd container runtime...
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.752645273+08:00" level=info msg="starting containerd" revision=7b11cfaabd73bb80907dd>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.846710940+08:00" level=info msg="loading plugin \"io.containerd.content.v1.content\">
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.848228792+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.860678255+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.860837088+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.btrfs>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.861426995+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.861515051+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devma>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.867431810+08:00" level=warning msg="failed to load plugin io.containerd.snapshotter.>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.867552495+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.nativ>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.869033051+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overl>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.872825736+08:00" level=info msg="loading plugin \"io.containerd.snapshotter.v1.zfs\">
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.873335273+08:00" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.873430995+08:00" level=info msg="loading plugin \"io.containerd.metadata.v1.bolt\"..>
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.873554181+08:00" level=warning msg="could not use snapshotter devmapper in metadata >
Dec 16 13:39:22 rpi64 containerd[579]: time="2021-12-16T13:39:22.873596514+08:00" level=info msg="metadata content store policy set" policy=shared

我已在 /lib/systemd/system/docker.service 中的“After=”中添加了:“local-fs.target”,但这并没有修复它。

我还能尝试什么?

答案1

按照这条评论,我补充道:

After=media-usb.mount media-ssd.mount
Requires=media-usb.mount media-ssd.mount

到:

/lib/systemd/system/docker.service

来自“单元文件”:

$ sudo systemctl list-unit-files|grep mount
media-ssd.mount                                                               generated       -
media-usb.mount                                                               generated       -

匹配挂载点:

$ df -kh
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       361G   85G  258G  25% /media/ssd
/dev/sdb1       7.3G  1.3G  5.7G  18% /media/usb

相关内容