Changing the Timezone to JST on Alpine Linux
Docker
2021-02-10 00:38 (5 years ago)

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
Related posts
Mistakes When Searching MySQL with datetime in Django Due to Time Zone Mismatch
How to Use freezegun in Django Tests to Set the Date One Day Ahead with USE_TZ=True
Fix: cryptography fails to install in Alpine Linux Docker images (3 workarounds)
Changed Django's Docker Environment from Alpine + uWSGI to Debian + Daphne → Ended up with uvicorn After All
Please rate this article (No signup or login required)
Current rating: 4.0 (2)
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.