How to run a docker container with scheduled task script

Discussion about Docker
Post Reply
User avatar
JuicePie82
Posts: 3
Joined: 21 Jan 2024, 23:56
United States of America

How to run a docker container with scheduled task script

Post 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.
User avatar
TMzethar
TerraMaster Team
Posts: 1226
Joined: 27 Oct 2020, 16:43

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

Post by TMzethar »

Code: Select all

docker start <container name or container ID>
To contact our team, please send email to following addresses, remember to replace (at) with @:
Technical team: support(at)terra-master.com (for technical support)
Service team: service(at)terra-master.com (for purchasing, return, replacement, RMA service)
User avatar
JuicePie82
Posts: 3
Joined: 21 Jan 2024, 23:56
United States of America

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

Post 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?
User avatar
JuicePie82
Posts: 3
Joined: 21 Jan 2024, 23:56
United States of America

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

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

Return to “Docker”