如何在GKE Pod中设置时区 [英] How to set up timezones in a GKE Pod

查看:85
本文介绍了如何在GKE Pod中设置时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将docker Linux部署到了gcloud gke pod.

I deployed docker Linux to gcloud gke pod.

我添加了下面的代码,试图在dockerfile中设置时区.此代码在本地docker中正确运行.但这在gcloud gke pod中不起作用.时区位于本地PST,GKE Pod中的时区仍处于UTC.请帮忙!

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

推荐答案

我不确定这在您的本地环境中如何工作.看起来您失踪了(Ubuntu,Debian):

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

dpkg-reconfigure -f noninteractive tzdata

总而言之,像这样:

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

博客有一个非常好的说明,包括操作方法 Alpine Linux .

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

这篇关于如何在GKE Pod中设置时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆