Sorry, I’m absolutely not a Linux expert :) I use /etc/fstab for the mounts, and to manually re-mount I run “mount -a”.
Comment on What is easiest solution to automatically resolve missing mounts due to e.g. a power outage?
freeearth@discuss.tchncs.de 9 months ago
Just specaluting… is it possible to mount NFS through systemd and make docker service dependent from that mount?
sylverstream@lemmy.nz 9 months ago
avidamoeba@lemmy.ca 9 months ago
This is a great opportunity to learn a bit of systemd then. Look at my other comment.
sylverstream@lemmy.nz 9 months ago
Awesome, yes, definitely will do. After years of using Linux, the whole systemd thing is still a bit of a black box to me. I know how to create /start/stop services etc but that’s about it. Thanks for the prompt replies!
avidamoeba@lemmy.ca 9 months ago
This is the answer. You can straight up make things dependent on .mount units that represent stuff in fstab. To add, you can create any number of systemd services that just check if something is “as you want it” and only then “start”. You simply make the Exec line “/bin/bash -c ‘your script here’”. Then you make whatever else you want dependent on it. For example I have such a unit that monitors for Internet connection by checking some public DNS servers. Then I have services that depend on Internet connection dependent on that.
samwwwblack@lemm.ee 9 months ago
You can use
RequiresMountsFor=
(egRequiresMountsFor=/media/storage-volume1
) instead of manually adding.mount
toAfter
/Requires
- you can then use.mount
files or fstab as you’re stipulating the path rather than a potentially changeable systemd unit name.The systemd.mount manpage also strongly recommends using fstab for human added mount points over
.mount
files.avidamoeba@lemmy.ca 9 months ago
Oh this is nice. I’ll probably start using it.
sylverstream@lemmy.nz 9 months ago
That’s interesting! I’ve converted all my docker run commands to docker compose, as I found that easier to manage. But, I guess you can’t do the dependencies like you have. Also, yours has the advantage it always pulls the latest.
key@lemmy.keychat.org 9 months ago
Doesn’t seem mutually exclusive. Replace the docker rm with compose down and the docker run with compose up.
avidamoeba@lemmy.ca 9 months ago
Exactly. In fact I have a few multi-container services with docker-compose that I have to write systems unit files for.
qaz@lemmy.world 9 months ago
Perhaps you could also add the mounts as dependencies to the Docker daemon.