The command below works nicely and puts "Hello from Docker." to out.txt

docker run -it --rm ubuntu echo "Hello from Docker." >> /home/ubuntu/out.txt``

Then when I open "sudo crontab -e" and put their line below, I am getting empty out.txt

* * * * *  docker run -it --rm ubuntu echo "Hello from Docker." >> /home/ubuntu/out.txt

Command below works and puts docker version into out.txt

* * * * *  docker -v >> /home/ubuntu/out.txt

from what I see "docker run" does not work for me from cron, and gives me no error/output. Do you have a clue why?

2 Answers 2


Try without options -it these are for interactive terminal. But you are using in a script with no terminal, no interaction.


Try with user root on crontab, the command will be:

* * * * * root docker run ....

  • thank you, i tried, no effect, i already was running that as root. because i am configuring cron with "sudo crontab -e", that runs it as root Dec 19, 2020 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.