Run container via a scheduled task on Synology

Currently reading
Run container via a scheduled task on Synology

8
0
NAS
Ds920+
Operating system
  1. Windows
Mobile operating system
  1. Android
I would like to be able to start a container via a basic command line:
docker container start rutorrent-vpn

However, when the nas runs the script, the container does not start and I get an error message :
line 1: docker: command not found

The script is running in Root.
The 1st script is the command: /usr/local/bin/docker container start rutorrent-vpn

The return is :
line 1: /usr/local/bin/docker: No such file or directory

On the other hand, I did inject the /usr/local/bin/docker into the PATH.
Here is the return of the $PATH export:
-sh: export: `/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin’: not a valid identifier

Could you please help me?
 
I use a task to start my portainer docker image. I do not call a script but call the command directly. And I run the task with user root. This works for me.

1634159806159.png


1634159868416.png
 
The error message inidcates that docker (as in the commandline client) can't be found.

Seems something is off with your docker installation: either the docker package is stopped os ir broken somehow?

I would suggest to remove and reinstall the docker package, then try again.
 
Last edited:
It's strange because, all of dockers are running :
1635160327730.png


If i'm launch this command by a script :
sudo docker-compose -f docker-compose.yml up -d

My error is :
docker-compose not found.

It's very strange because by entering the commands directly in SSH without going through a script it works
 
It's strange because, all of dockers are running :
View attachment 4672

If i'm launch this command by a script :
sudo docker-compose -f docker-compose.yml up -d

My error is :
docker-compose not found.

It's very strange because by entering the commands directly in SSH without going through a script it works
Then you have to install docker-compose or to update it when it's broken.
 
No solution ?
Have you actualy ever tried to remove the docker package and reinstall it?

Your installation obviously is messed up or you have a race-condition. Just because some parts of docker work as expected, does not necessarily mean the whole docker package works as expected. In your case it does not.

Please add a ls -la before your docker line (I would have copied the string, if you wouldn't have shared it as screenshot). It will indicate whether the symlink to the docker binaries actualy exist at the point in time before your script starts, or does not exist.

You could delay the execution and wait for the symlink beeing available before you actualy run your docker command:

Bash:
while [ ! -e /usr/local/bin/docker ]; do
  echo "waiting for the docker symlink"
  sleep 1
done
{your docker command here}

And on a closer look: why do you event want to use a scheduled task to restart a container?! The UI specificly provides a checkbox for this in the container settings.
 
Have you actualy ever tried to remove the docker package and reinstall it?

Your installation obviously is messed up or you have a race-condition. Just because some parts of docker work as expected, does not necessarily mean the whole docker package works as expected. In your case it does not.

Please add a ls -la before your docker line (I would have copied the string, if you wouldn't have shared it as screenshot). It will indicate whether the symlink to the docker binaries actualy exist at the point in time before your script starts, or does not exist.

You could delay the execution and wait for the symlink beeing available before you actualy run your docker command:

Bash:
while [ ! -e /usr/local/bin/docker ]; do
  echo "waiting for the docker symlink"
  sleep 1
done
{your docker command here}

And on a closer look: why do you event want to use a scheduled task to restart a container?! The UI specificly provides a checkbox for this in the container settings.
You are the best ! It works.
 
Then you have to install docker-compose or to update it when it's broken.
Same here
It's strange because, all of dockers are running :
View attachment 4672

If i'm launch this command by a script :
sudo docker-compose -f docker-compose.yml up -d

My error is :
docker-compose not found.

It's very strange because by entering the commands directly in SSH without going through a script it works
This worked for me:

Task script:

Code:
#!/bin/bash
cd /volume1/docker/[directory where docker-compose.yml is stored]/
sh ../update.sh

update.sh in the directory /volume1/docker:

Code:
docker-compose down && docker-compose pull && docker-compose up -d

You could include a docker-compose rm -f in order to make sure the container is cleaned up:

Code:
docker-compose down && docker-compose rm -f && docker-compose pull && docker-compose up -d

Also, you could replace the && with ; or & in order to make sure the container runs should the cleaning or pull fail for whatever reason.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

I have no idea what you are doing, but I just tested it based on the instructions of the guide you linked...
Replies
11
Views
2,762
  • Question
It is realy not complicated to translater container arguments to Synology UI settings. Here is what each...
Replies
2
Views
1,876
I am trying to solve a similar case: I am going to run my nginx:stable-alpine web server in Docker, with...
Replies
16
Views
10,624
@one-eyed-king , I have tried your first step: sudo synogroup --add docker and encounter the following...
Replies
11
Views
31,037
Done on both my NAS'es running Docker! :) Thanks again!
Replies
9
Views
13,493

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending threads

Back
Top