Page 1 of 1

How to run a docker container with scheduled task script

Posted: 22 Jan 2024, 00:03
by JuicePie82
Hi there. I am new to TOS 5.1 and TOS in general. I have a docker container set up and it runs fine when i run it through the docker Manager however i cant figure out how to use the TOS Scheduled tasks tool to run that same container.
How do i get the command to execute this container on a schedule and create a task for it...i.e. start it at 9am? If there is another thread on here for this..i couldnt find it! Thanks in advance.

Re: How to run a docker container with scheduled task script

Posted: 22 Jan 2024, 18:46
by TMzethar

Code: Select all

docker start <container name or container ID>

Re: How to run a docker container with scheduled task script

Posted: 23 Jan 2024, 00:05
by JuicePie82
TMzethar, i figured that was all i needed as well.
That command does work when i putty into the TNAS and type it directly "docker start 1f94aa587d76" is the id.

When i use this command in the scheduled task and run the task, it says "operation succeeded!" but the container is not running when i check at that point. After the logs are emailed to me..this is the output of the command from the scheduler.
"-bash: line 1: docker: command not found"
Is it possible the security context is different from the scheduler?

Re: How to run a docker container with scheduled task script

Posted: 23 Jan 2024, 00:56
by JuicePie82
I think i figured it out. It looks like the execution context of the scheduler is different than a putty instance. It doesn't honor the PATH variables in that environment i guess...
With that said, I had to run the command with the absolute directory of the docker install..then it worked as intended.
In my case, Volume1 is where my OS/docker app is installed so it works like this:

/Volume1/@apps/docker/dockerd/bin/docker start 1f94aa587d76

Now i know...