Changing the Timezone to JST on Alpine Linux

Docker
2021-02-10 09:38 (3 years ago) ytyng

Two Implementation Methods

RUN apk --no-cache add tzdata \
&& cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \
&& apk del tzdata


Alternatively

ENV TZ=Asia/Tokyo
RUN apk --no-cache add tzdata


Choose one.

Combining the first method with ENV TZ= does not work well.

Verification Method

Check if the date command returns JST.

$ date
Wed Feb 10 09:45:26 JST 2021

Difference

The latter method leaves all time zones within the image.

The size is approximately 3.3 MB.

If your application uses time zones, the latter method is preferable.

Verification Method in Django

./manage.py shell
>>> from django.utils import timezone
>>> timezone.now()
>>> timezone.now().hour

Current rating: 4

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011