I am trying run a docker container with python code and crontab (scheduler) below is my script:
Docker file
FROM ubuntu:latest
MAINTAINER [email protected]
RUN apt-get update && apt-get install -y software-properties-common && apt-get install -y python cron vim
# Copy hello-cron file to the cron.d directory
COPY my-crontab /etc/cron.d/my-crontab
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/my-crontab
ADD config.py /
ADD index.py /
RUN chmod a+x config.py index.py
# Apply cron job
RUN crontab /etc/cron.d/my-crontab
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
#CMD cron && tail -f /var/log/cron.log
CMD ["cron", "-f"]
My crontab
*/2 * * * * /index.py > /dev/console
When I create the docker file and run the code its not responding with anything. Please can someone suggest how to modify the docker file to run the script?