Closed
Description
I tried many methods, but it still showed UTC. I tried three methods as follows:
1 RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2 RUN echo "Asia/Shanghai" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
3 ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
I wrote these commands in the Dockerfile respectively, none of them did work.
Could you tell me how to set the timezone please? Thanks very much
Activity
tianon commentedon Jan 24, 2016
NeverWait commentedon Jan 24, 2016
Thanks, I go to have a try now
andyshinn commentedon Mar 8, 2016
Based on the
Dockerfile
shown it looks liketzdata
may have indeed been missing. Please reopen if this is still an issue for you. We do pull intzdata
at build time to specifically grab just the UTC timezone file. So, if that is causing issues this could be considered a bug.kklepper commentedon May 8, 2016
Why does this not work? (Usually people set a soft link, but even copy doesn't do the trick.)
kklepper commentedon May 9, 2016
On the alpine bug list, Christian Kampka advised
He also said
I don't understand this, but after adding -U and substituting TZ in the Dockerfile it works now as intended.
danielgusmao commentedon Jan 15, 2017
#
Install base packagesRUN apk update
RUN apk upgrade
RUN apk add ca-certificates && update-ca-certificates
#
Change TimeZoneRUN apk add --update tzdata
ENV TZ=America/Bahia
#
Clean APK cacheRUN rm -rf /var/cache/apk/*
renanbr commentedon Sep 25, 2017
Sorry for commenting on a closed issue, but sometimes I just want to deploy a simple application using Docker Compose with some alpine-based containers inside... then I'm forced to override every dockerfile (or use on-the-fly configuration).
TZ
variable works for debian-based images, and it's great :-) Why not for alpine?Even if it's not a bug, would we consider taking it as an usage issue?
StalkAlex commentedon Nov 1, 2017
After using previous code it started to show current time zone as I understand, but time stays as before.
Wed Nov 1 12:12:45 +06>-6 2017
But real time is
18:12:45
. Could someone explain me what this is+06>-6
and how setup time correctly?tianon commentedon Nov 1, 2017
@StalkAlex no idea where that
+06>-6
is coming from, but the following works fine for me:In a
Dockerfile
, that would look something like this:42 remaining items