Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Script] check if there are any Dockers that are not working and restart them

Featured Replies

Script for checking and starting Docker containers.

 

Step 1: Install the User Scripts Plugin

1. Open Unraid Web UI: Go to your Unraid server's web interface.

2. Go to Plugins: Navigate to the "Plugins" tab.

3. Install User Scripts: If you don't have it installed, find and install the User Scripts plugin from the Community Applications.

 

Step 2: Create Your Script

1. Open User Scripts: After installation, go to the "User Scripts" tab.

2. Add a New Script: Click on "Add Script".

3. Name Your Script: Give it a descriptive name, e.g., Check Docker Containers.

4. Edit the Script: Click on the script name to edit it, and paste your modified script into the editor:

 

#!/bin/bash

# List of Docker container names or IDs to check
containers=("container1" "container2" "container3")

# Check if Docker is running
if ! systemctl is-active --quiet docker; then
    echo "Docker is not running. Please start Docker and try again."
    exit 1
fi

# Loop through each specified container and check its status
for container in "${containers[@]}"; do
    if ! docker ps -a --format '{{.Names}}' | grep -q "^$container$"; then
        echo "Container $container does not exist."
        continue
    fi

    status=$(docker inspect --format='{{.State.Status}}' "$container" 2>/dev/null)
    if [ $? -ne 0 ]; then
        echo "Failed to inspect container $container. It may not exist."
        continue
    fi

    if [ "$status" != "running" ]; then
        echo "Container $container is not running. Attempting to start it."
        if docker start "$container"; then
            echo "Container $container started successfully."
        else
            echo "Failed to start container $container."
        fi
    else
        echo "Container $container is running."
    fi
done

 

Step 3: Schedule the Script

1. Set Schedule: In the User Scripts page, set the frequency to "Every 15 minutes".

2. Save the Script: Click "Save Changes" to save the script.

 

Additional Tips

1. Customize Container Names: Replace container1, container2, and container3 in the script with the actual names or IDs of your Docker containers.

2. Access Logs: You can view logs from the script runs directly in the User Scripts interface.

 

 

If you have any questions or need further assistance while setting it up, feel free to ask. I'm here to help!

Edited by ngf24

  • ngf24 changed the title to [Script] check if there are any Doctors that are not working and restart them

Hopefully you meant dockers and not Doctors. 😁

Thanks for the script.

  • ngf24 changed the title to [Script] check if there are any Dockers that are not working and restart them

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.