Set up to allow cPanel users to run application in background (not root) - scratching my head on this one ..

TechBill

Active Member
Aug 7, 2011
44
4
58
I installed and setup docker and nginx as proxy as root so cPanel users could load and run dockers on their accounts.

The ngnix was installed using WHM console and docker was installed with yum installer. I had to manually added a vhost file and edit it for each users who want to run docker on their account with using their domain name. I created a vhost using a user cPanel sub-domain and a port not in use for docker.

The first test I did was to log in as a cPanel and open terminal then execute a docker with the port number that was assigned in vhost file to the sub-domain. It worked great so far.

My question is .. How do cPanel user (not root or su) execute an application like docker but leave it running in background even if they log out of cPanel.

I thought of using cron job to execute the script with docker commands but will cPanel cron job re-execute an script if the server reboots or restarted?

Is there another way for cPanel to set up scripts to be run all time in background that only need to be executed once like docker or re-execute if needed after a reboot?

Thank you,
Bill
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
12,499
1,971
363
cPanel Access Level
Root Administrator
Hey there! In general, this sounds more like you want a daemon than a script, as that isn't associated with a certain user, but does run as root. If you have a certain script in mind you could add the "&" symbol to the end of it to run in the background of bash, but I'm not sure if that's what you're looking for or not.

Cron jobs are not re-executed after a reboot, until the next time they are triggered.

cPanel doesn't officially support Docker yet (although we're getting there) so it's possible that some of this will work better once that is supported.
 

TechBill

Active Member
Aug 7, 2011
44
4
58
Hey there! In general, this sounds more like you want a daemon than a script, as that isn't associated with a certain user, but does run as root. If you have a certain script in mind you could add the "&" symbol to the end of it to run in the background of bash, but I'm not sure if that's what you're looking for or not.

Cron jobs are not re-executed after a reboot, until the next time they are triggered.

cPanel doesn't officially support Docker yet (although we're getting there) so it's possible that some of this will work better once that is supported.
Daemon is the word I was looking for ..

The docker I am setting up is n8n - https://n8n.io/ I do have it working and running on cPanel by using this command as a cpanel user in terminal:

docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n

I tried the "&" symbol at the end and it's running now in the background so that worked. Does it restores if there was a reboot or the user have to go back and execute it after a reboot?

cPanel going to support Docker in future? Awesome .. can't wait to see that!

Thank you.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
12,499
1,971
363
cPanel Access Level
Root Administrator
You'd have to have the command executed again after a reboot in order for that process to restart in the background.

We'll make an announcement once we support Docker, but I know it's in the works and something a lot of users have asked for.
 

TechBill

Active Member
Aug 7, 2011
44
4
58
You'd have to have the command executed again after a reboot in order for that process to restart in the background.

We'll make an announcement once we support Docker, but I know it's in the works and something a lot of users have asked for.
We're looking forward to it!

For now, we will just tell the users to restart their dockers if for any reason server rebooted like a keneral upgrade etc.