I recently have a problem when I want to execute docker-compose command in crontab.
I have a docker-compose YAML file that defined all the services I need, say “docker-compose.yml". And I also have a Makefile in which I had written some command to do something.
My makefile is:
.PHONY operate
operate:
/usr/local/bin/docker-compose -p /project -f ~/docker-compose-production.yml run rails env
This make script worked fine when it executed in shell. It listed all the environment var I defined in docker-compose.yml. But when I putted it in crontab.
The result became strange, it listed nothing but only the $PATH
.
My crontab file is:
57 21 * * * make -f ~/Makefile operate >~/temp 2>&1
I guess there must be some environment var that docker-compose must have but I don’t know. Do you have any idea about this problem?
you can use
10 3 * * 0 /usr/local/bin/docker-compose -f /www/ilanni.com/docker-compose.yml start > /dev/null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With