I want to create docker container with python script, which creates txt file with now() date and cron to execute this script every minute. But cron doesn't work.
crontab file
* * * * * /app/wrapper.sh >> /proc/1/fd/1 2>/proc/1/fd/2
Dockerfile
FROM python:3.10
RUN apt-get update && apt-get -y install cron vim
WORKDIR /app
#RUN pip install requests pandas
COPY crontab /etc/cron.d/crontab
COPY docker.py /app/hello.py
COPY wrapper.sh /app/wrapper.sh
RUN chmod 0644 /etc/cron.d/crontab
RUN chmod +x /app/hello.py
RUN chmod +x /app/wrapper.sh
RUN /usr/bin/crontab /etc/cron.d/crontab
# run crond as main process of container
CMD ["cron", "-f"]
wrapper.sh
#!/bin/bash
/usr/local/bin/python3 /app/hello.py >> /app/cron_log.txt 2>&1
After connecting to container via Docker Dekstop on windows, ps aux there is cron -f active, crontab -l show me my crontab file task. I waited for some minutes and there is any txt file. I thought python doesn's work, but after 'python docker.py' command everything works great.