Jump to content

Simplest way to run python script in Unraid


rvs007

Recommended Posts

I'm asking the question here because I've been trying to create a docker container to run a simple python script and I'm in way over my head.  So hopefully someone here can point me in the right direction.

 

A little background... I've migrated from a Windows Server (2012R2) to an Unraid server and have gotten everything set up.  I'm now migrating all the little servers/apps that I had running on the Windows Server, one being a little python script called Alarmserver that I have running to allow the Envisalink module attached to my DSC alarm system to talk to a plugin in Homebridge.  The server is a bunch of .py files along with a alarmserver.cfg where I've edited with the configuration settings needed for alarmserver to run.

 

I'm trying to move this to Unraid.  I want to avoid having to run a Windows VM to run this in a Windows environment.  I figure a docker container would be the most efficient way to do this.  And I've found numerous docker containers in Docker Hub created by other users for this.  

 

But since I already have a folder with the script and a customized configuration file already set up, I'd like to just take that folder and put it in a container and run it, similar to what I'm doing in Windows. 

 

c:\python27\python.exe c:\alarmserver\alarmserver.py -c c:\alarmserver\alarmserver.cfg

 

So what's the simplest way to get this into a docker container in Unraid?  Thanks in advance.

Link to comment
  • 3 months later...

Depending on what the script needs access to the proper way to do python in unraid is to run it in a docker container. You can either create a custom image with all of your python files included (better if you need to install a bunch of packages link) or use a default container and bind mount in the script directory. The second option might look something like this 

docker run --rm -it -v /host/scripts:/container/scripts -w /container/scripts python:3.10 python main.py -some-arg

 

  • Thanks 2
Link to comment
  • 1 year later...
On 7/18/2023 at 5:49 PM, primeval_god said:

Depending on what the script needs access to the proper way to do python in unraid is to run it in a docker container. You can either create a custom image with all of your python files included (better if you need to install a bunch of packages link) or use a default container and bind mount in the script directory. The second option might look something like this 

docker run --rm -it -v /host/scripts:/container/scripts -w /container/scripts python:3.10 python main.py -some-arg

 

 

Thank you for good information and help!

 

I need an access to custom network and it does not work if I create a temporary docker container with a docker run command. So, I need to create a custom image. In addition to the generic docker tutorial from the link above, is there a good tutorial that would present the unraid specific details for docker containers? 

Link to comment
18 hours ago, Ruato said:

I need an access to custom network and it does not work if I create a temporary docker container with a docker run command.

A custom docker network? You can specify any existing docker network in your run command.

18 hours ago, Ruato said:

In addition to the generic docker tutorial from the link above, is there a good tutorial that would present the unraid specific details for docker containers? 

I cant think of one off hand. For a python script container I cant think of much unRAID specific stuff to worry about. 

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