I run quite a few Docker containers on my Unraid homelab, and some I don’t need 24/7. Some containers like development tools and media utilities don’t need to stay active overnight. I wanted to automatically turn off Docker containers on Unraid during off-hours to save resources and reduce unnecessary background processes.
After testing various approaches, I found a simple solution using the User Scripts plugin that handles both stopping and starting containers based on time of day. If you’re new to running Docker containers on Unraid, check out my complete guide on how to install Unraid NAS to get your server up and running first.
Before you can automatically turn on or off Docker containers, install these two plugins from the Unraid Community Applications:
Both plugins are available in Apps → search for “User Scripts” and install them by squid. Over the years the maintainers have changed though, but the names of the scripts remained the same.
Here’s the complete script I created to automatically turn on Docker containers on Unraid at 10 AM and stop them at 2 AM:
#!/bin/bash
# Auto start/stop containers based on time
HOUR=$(date +%H)
if [ "$HOUR" -eq 2 ]; then
docker stop code-server obsidian pgadmin4 phpmyadmin lanspeedtest krusader
echo "$(date): Containers stopped"
elif [ "$HOUR" -eq 10 ]; then
docker start code-server obsidian pgadmin4 phpmyadmin lanspeedtest krusader
echo "$(date): Containers started"
fi
Replace the container names with your own. In my case, I’m scheduling development and admin tools that I only use during working hours. For inspiration on which containers might benefit from scheduling, see my guide on the top self-hosted Docker apps for Unraid server.
If you need to figure out exact container names, you can either do it via GUI or run this command:
docker ps -a --format "table {{.Names}}\t{{.Image}}"
or
docker ps --format "table {{.Names}}\t{{.Status}}"
For example, if you’re running ytptube on Unraid for YouTube archiving, you might want to schedule it to run only during specific hours when you’re actively downloading content.
containers_auto_schedulercontainers_auto_scheduler script to this category, save it0 2,10 * * *The cron expression 0 2,10 * * * runs the script at 2:00 AM (stop) and 10:00 AM (start) every day.
You can modify the timing by adjusting the cron schedule:
0 1,9 * * * – Stop at 1 AM, start at 9 AM0 23,8 * * * – Stop at 11 PM, start at 8 AM0 2,10 * * 1-5 – Weekdays only (Monday to Friday)0 3,11 * * 6-7 – Weekends only (Saturday and Sunday)This approach to automatically turn off Docker containers on Unraid has been running flawlessly on my homelab for months, saving resources without requiring manual intervention. If you’re also running monitoring tools like GoAccess, you can monitor your Nginx Proxy Manager with GoAccess on Unraid to track which containers are consuming the most resources.
When scheduling containers, consider which services need to remain accessible. Critical infrastructure like authentication services should never be scheduled to stop. If you’re implementing single sign-on across your containers, my guide on setting up Authelia SSO on Unraid with Nginx Proxy Manager explains how to protect your services whilst maintaining 24/7 availability for essential systems.
For more advanced container management, you can also reference the official Unraid Docker documentation and the User Scripts plugin documentation.