wodby / alpine

Alpine Linux docker container image
https://alpinelinux.org/
MIT License
7 stars 4 forks source link

Optional Timezone support #2

Closed jgribonvald closed 2 years ago

jgribonvald commented 2 years ago

It would be great to pass an argument to be able to set the timezone.

To set the timezone the alpine doc permit it from: https://wiki.alpinelinux.org/wiki/Alpine_setup_scripts#setup-timezone so passing a value for the -z argument would be good

But it seems that seting the TZ ENV argument could be suffisant: https://stackoverflow.com/questions/68996420/how-to-set-timezone-inside-alpine-base-docker-image

On an other way you can do like that: https://quaded.com/docker-apline-configure-timezone/

Else on ubuntu image I'm doing like that:

# Set TIMEZONE
ENV TZ=Europe/Paris
RUN echo $TZ > /etc/timezone && \
    apt-get update && apt-get install -y tzdata && \
    rm /etc/localtime && \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata && \
    apt-get clean
jgribonvald commented 2 years ago

Finally as you are installing tzdata we can pass the argument TZ with timezone and it work ! I've found this exchange about: https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes