Kaptain.
Telegram /
LinkedIn /
Email /
GIT /
RSS /
GPG /
Заказ печатных плат

№ 9577 В разделе
Sysadmin
от November 25th, 2018,
В подшивках: Cron, Docker
At first, create your cron file with usual crontab lines and name it mycrontab_lines
*/5 * * * * /app/cron_script.sh
Now create your cron_script.sh
#!/bin/bash # load env variables source /etc/profile . ~/.profile python3 /app/mycronapp.py
Ok, you ready now to create Dockerfile like this:
FROM python:3
# install cron service
RUN apt-get ${APT_FLAGS_COMMON} update && \
apt-get ${APT_FLAGS_PERSISTENT} -y install cron && \
apt-get ${APT_FLAGS_COMMON} autoremove && \
apt-get ${APT_FLAGS_COMMON} clean && \
rm -rf /var/lib/apt/lists/*
# bla bla bla copy app.py
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# install python app
COPY app.py .
COPY mycronapp.py .
# make cron
COPY mycrontab_lines .
COPY cron_script.sh .
RUN chmod 0755 run_previewer.sh
RUN chmod 0644 mycrontab_lines
RUN crontab mycrontab_lines
# start cron service before start blocking application
CMD service cron start && \
python ./app.py
Build and run container.
Fortune cookie: Today's spam: Click to Be King of the Bedroom
Leave a Reply