I had trouble running containers automatically after booting.
The data volumes are mapped to mounted shared drives and this works as expected when starting the comtainers manually with docker-compose up
.
I've setup the restart: always
policy in my docker-compose.yml
so containers would be started after I reboot the OS.
This resulted in the container not seing the content of the shared drives.
The issue is that the containers would start before the drives were mounted.
To fix the issue I added a dependency on the docker daemon service so it would start after the shares are mounted.
First, create a systemd drop-in directory for the docker service:
mkdir /etc/systemd/system/docker.service.d
Then create a file called /etc/systemd/system/docker.service.d/remote-fs.conf
with the following content:
[Unit]
After=remote-fs.target
Read current dependencies:
sudo systemctl show docker --property After
> After=network.target systemd-journald.socket docker.socket system.slice basic.target
Flush changes:
sudo systemctl daemon-reload
Check that it worked:
sudo systemctl show docker --property After
> After=remote-fs.target network.target systemd-journald.socket docker.socket system.slice basic.target
I found how to do this from: