Problem
If you restart the host system, such as for patching, the dependencies within the Docker Compose files may not be recognized. As a consequence, MySQL is up after Simplifier, causing Simplifier to have no database connection and become stuck.
Solution
Overview
- disable autostart of all container in docker compose file
- create service to start Simplifier
- configure service to be automatically executed during starting up the system
Implementation Details
Change docker-compose.yml
For all services, you need to change the value of the restart property. The default is:
restart: always
For all services, change this to
restart: no
Create a startup script
On your Linux host create a new bash script, e.g. with
nano /var/lib/simplifier/bin/startup.sh
Enter this content for this script:
#!/bin/sh docker compose -f /var/lib/simplifier/bin/docker-compose.yml up -d echo "this startupscript has been executed via ron at reboot" + $(date) >> /var/lib/simplifier/startup.log
Make it executable:
chown u+x /var/lib/simplifier/bin/startup.sh
Create a new system service
On your Linux host create a new service, e.g. with
nano /etc/systemd/system/start-simplifier-docker.service
Enter this content for this service:
[Unit] Description=Start Simplifier Docker Container After=docker.service Requires=docker.service [Install] WantedBy=multi-user.target [Service] Type=oneshot ExecStart=/bin/sh /var/lib/simplifier/bin/startup.sh RemainAfterExit=yes User=root Group=root WorkingDirectory=/var/lib/simplifier/bin/ Restart=on-failure
Enable the new service
Update Service Daemon
systemctl daemon-reload
Test the Service Script
systemctl start start-simplifier-docker.service
Check the Logs
journalctl -u start-simplifier-docker.service
If that works as expected, you can use the following command to make sure it starts at boot.
systemctl enable start-simplifier-docker.service