How to set up timezones in a GKE Pod

2019-08-07 12:56发布

I deployed docker Linux to gcloud gke pod.

I added the code bellow, trying to set up the time zone in the dockerfile. This code is running correctly in a local docker. But it does not work in gcloud gke pod. The timezones are in local PST, timezones in GKE Pod are still in UTC. Please help!

ENV TZ=America/Los_Angeles
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

1条回答
淡お忘
2楼-- · 2019-08-07 13:33

I'm not sure how this is working on your local environment. Looks like you are missing (Ubuntu, Debian):

dpkg-reconfigure -f noninteractive tzdata

So in summary something like this:

echo America/Los_Angeles >/etc/timezone && \
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata

This blog has a very good explanation, including how to do it Alpine Linux.

查看更多
登录 后发表回答