1 year ago

#389124

test-img

Nurbek

How can I add cron jobs in docker image

FROM python:3.10.2

WORKDIR /usr/src/app

COPY ./requirements.txt .

RUN pip install -r requirements.txt
RUN apt-get update && apt-get install -y cron curl


EXPOSE 8084

COPY . .

CMD ["flask", "run", "--host", "0.0.0.0"]

just a function to test

@crontab.job(minute='*')
def writeones():
    with open('t.txt', 'a') as file:
        file.write("Now the file has more content!")

But after command docker-compose up I type flask crontab add and its output:


no crontab for root

python

docker

cron

0 Answers

Your Answer

Accepted video resources