0

Here is my Dockerfile (or at least the interesting part):

FROM debian:7
MAINTAINER pjb <pjb@example.com>

RUN apt-get update && apt-get install -y build-essential ntp cron

ADD config/job /etc/cron.d/job
ADD config/cron /etc/default/cron
RUN chmod 0644 /etc/cron.d/job

CMD cron && tail -f /var/log/cron.log

I use this command to run the container:

docker run -d --restart=always -e "TZ=Europe/Paris" -v /etc/timezone:/etc/timezone:ro --name=mycontainer pjb/repo

When I enter the container (docker exec -it mycontainer bash) all looks good to me:

/etc/cron.d/job:

* * * * * root /bin/date >> /var/log/cron.log 2>&1

/etc/default/cron:

READ_ENV="yes"
TZ="Europe/Paris"

/etc/timezone:

Europe/Paris

And /bin/date gives me the correct time.

But the date I get inside /var/log/cron.log is UTC time. It should be UTC+1.

0

I ended up setting the timezone directly in my application (run by cron), and it works as expected.

ENV['TZ'] = 'Europe/Paris'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.