Jump to content

user for docker container restarts


Recommended Posts

Hi,

im looking for a solution to let a user restart / update a docker container hosted in unraid.

I wont give a full access to unraid gui. Is there a possible way to add a user where can just restart / start / stop and update a running container?

It would also fine with a second gui in a container or so that can do this stuff

Link to comment

Short answer, no, there is currently no way to add limited access GUI users.

 

Since docker start stop and restarts are easy on the command line, you can do scripting that looks at a user accessible share location for input. Updates are probably possible, but I have no experience doing updates from the CLI.

The script would watch for and act on the existence of a specifically formatted file to show up or change in a user share location.

The user would connect to the SMB share that has permissions for that user to create or modify files, and manipulate the file(s) the script is watching for.

As a quick example, you could look for the existence of a file named restart.txt, when found the script would restart the container and delete the restart.txt file.

Link to comment
  • 5 months later...

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>

 

Edited by t0mi
Link to comment

i tried this workaround and it worked fine via nextcloud... how do you fixed the nextcloud issues? if the file is removed via script it is shown in nextcloud as well and not removed there after a few minutes so in worstcase i can't create a new one because for nextcloud it still exist

Link to comment

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...