Docker returns connection error after being setup as cron job

by goose   Last Updated January 01, 2018 13:00 PM

I have a docker container on ubuntu 16.04 and I want to run a docker command periodically. After checking the command runs successfully from the command line I've setup a crontab with the following:

*/1 * * * * sudo docker run {image-name} python3 /{path-to-scrip}/script.py

This seems to work ok until the script outputs something after which point the crons don't run and it stops docker from working with the following message:

docker: Error response from daemon: connection error: desc = "transport: dial unix /var/run/docker/containerd/docke
r-containerd.sock: connect: connection refused".

I've read that stdout may be the problem and I've tried the following in crontab:

*/1 * * * * sudo docker run {image-name} python3 /{path-to-scrip}/script.py > /home/logs 2>&1

This is running on a virtual machine and restarting the instance gets me back to square one where docker runs.

I'm not the most experienced sys admin and suspect I've made a naive mistake, but I don't know how to progress this? What should I have done to setup the cron?



Related Questions



Run cron in centOS as user process, not daemon

Updated March 28, 2015 17:00 PM

Crontab not picking up new conjob

Updated April 11, 2017 13:00 PM

PHP7-FPM Docker CMD results in 502 Nginx Error

Updated March 06, 2018 14:00 PM