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
3,301
If the Container Manager package is installed and started, the unix domain socket /var/run/docker.sock...
Replies
1
Views
397
Another aspect that might indicate it is that the swarm mode finally works! It is the first Synology...
Replies
4
Views
955
Replies
3
Views
1,005
I can’t find any option to restore just the settings. 1710356648 Phew, managed to fix it. Within the...
Replies
4
Views
736
  • Question
Open an issue on that GitHub page. The developers will be glad to assist. OP has posted two threads on...
Replies
5
Views
1,387
I'm happy with email notifications but in v0.3.3 of dockcheck the author added apprise notifications...
Replies
4
Views
1,670

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