-
Notifications
You must be signed in to change notification settings - Fork 280
Open
Description
Thanks for posting this, it got me started. I found an approach (using crontab - < /path/to/crontab) that worked better for me. Thought I would post it here in case others found it useful.
modified Dockerfile
@@ -1,19 +1,16 @@
FROM ubuntu:latest
MAINTAINER docker@ekito.fr
-# Add crontab file in the cron directory
-ADD crontab /etc/cron.d/hello-cron
-
-# Give execution rights on the cron job
-RUN chmod 0644 /etc/cron.d/hello-cron
-
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
#Install Cron
RUN apt-get update
RUN apt-get -y install cron
+# Install the crontab
+ADD crontab /tmp/crontab
+RUN crontab /tmp/crontab && rm /tmp/crontab
# Run the command on container startup
CMD cron && tail -f /var/log/cron.log
modified crontab
@@ -1,2 +1,2 @@
-* * * * * root echo "Hello world" >> /var/log/cron.log 2>&1
+* * * * * echo "Hello world" >> /var/log/cron.log 2>&1
# Don't remove the empty line at the end of this file. It is required to run the cron job
mike-brady, santiagocasasrey, cornettolo, plhery, Chubasik and 10 more
Metadata
Metadata
Assignees
Labels
No labels