So I have this Dockerfile:
From ubuntu:16.04
RUN apt-get update && apt-get -y install cron sudo watch vim
RUN useradd --create-home --shell /bin/bash mark
RUN mkdir /joel
COPY ./crontab_delete /joel
WORKDIR /joel
RUN ls -al
RUN cron -f
RUN crontab myCrontab
I then do docker exec --user mark -it CONTAINER_NAME bash
and I can see that the cron is running but I then need to execute crontab myCrontab
which works from being inside the container via docker exec...
but if you put it as the last command
since I need to start the cron in foreground BEFORE running my crontab file
the docker build...
hangs at RUN cron -f and doesn't allow the last command to run
UPDATES
The linked post no longer work as of 2018; maybe someone has an updated Dockerfile they could share ? The above Dockerfile doesn't start the cronjob for me but when I do ps -aux | grep cron
I can see that the cron service
is running