Systemd
如何延遲 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 中將“local-fs.target”添加到“After=”,但這並沒有修復它。
我還能嘗試什麼?
根據此評論,我補充說:
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