INT 21h

Hi, I am Vladimir Smagin, SysAdmin, DevOps and barely good guy. Telegram Email / GIT / Микроблог / Thingiverse / GPG

Cron inside your Docker image with python app

№ 9577 В разделе "Администрирование" от November 25th, 2018,

At first, create your cron file with usual crontab lines and name it mycrontab_lines

*/5 * * * * /app/

Now create your

# load env variables
source /etc/profile
. ~/.profile

python3 /app/

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

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# install python app

# make cron
COPY mycrontab_lines .
RUN chmod 0755
RUN chmod 0644 mycrontab_lines
RUN crontab mycrontab_lines

# start cron service before start blocking application
CMD service cron start && \
    python ./

Build and run container.

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *


Микроблог перейти

# 2019-04-14 20:17:08

офигенный проект БК на rasperry pi

# 2019-04-05 19:15:52

# 2019-03-29 19:32:52

Интересное SDK на NodeJS для программирования ESP8266

© Vladimir Smagin, 2005-2019. Копирование материалов без разрешения запрещено. GPG DA4CD0F5E222EA727D6A40C413BCE12E5618F071 *

Fortune cookie: Q: How many people from New Jersey does it take to change a light bulb? A: Three. One to do it, one to watch, and the third to shoot the witness.