How to set up timezones in a GKE Pod

11/16/2018

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
-- tuan huynh
docker
gcloud
google-kubernetes-engine
kubernetes
timezone

1 Answer

11/16/2018

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.

-- Rico
Source: StackOverflow