I created a Docker image with Dockerfile for executing a script like get_date.sh
on the container but it's not working.
get_date.sh
contains:
date
date +"%FORMAT"
var=$(date)
var=`date`
echo "$var">>/var/log/tito_time.log
Dockerfile:
FROM ubuntu:latest
MAINTAINER docker@ekito.fr
RUN apt-get update && apt-get install -y cron && apt-get install nano
COPY get_date.sh /etc/cron.d/get_date.sh
RUN chmod 0644 /etc/cron.d/get_date.sh
RUN crontab -l | { cat; echo "* * * * * bash /etc/cron.d/get_date.sh"; } | crontab -
CMD cron
The image is created correctly. Running crontab -l
in a container shell gives me:
root@92ce260aeb21:/# crontab -l
* * * * * bash /etc/cron.d/get_date.sh
crontab doesn't execute get_date.sh
on the container.