Hello, i searched for the exact same (im running a gameserver docker for my friends and sometimes the server have to be restarted)
Im also hosting nextcloud so i created a user for them where if they need to restart they just create the file restart.txt
the script:
#!/bin/bash
# Name of the Docker container
CONTAINER_NAME="CoreKeeper"
# Path to the watch file
RESTART_FILE="/mnt/nvmepool/appdata/nextcloud/data/corekeeper/files/restart.txt"
# Infinite loop to check for the file
while true; do
if [ -f "$RESTART_FILE" ]; then
echo "File $RESTART_FILE found. Restarting the Docker container..."
# Restart the Docker container
docker restart $CONTAINER_NAME
# Delete the file to reset the process
rm -f "$RESTART_FILE"
echo "Docker container has been restarted and the file has been deleted."
fi
# Wait for 60 seconds before checking again
sleep 60
done
UPDATE: do it as userscript in settings and forget that below
In Unraid you open the console and create the restartdockercontainer.sh
Create new file and paste the code inside
nano restartdockercontainer.sh
CTRL+X and save it with Y
use following command so the script can be executed
chmod +x restartdockercontainer.sh
you then can run it with
nohup ./restartdockercontainer.sh &
if you restart your unraid maschine u would need to start it again,
you can check if it is running with command
ps
and kill it with
kill <id>