修改时区
通过环境变量设置时区
apiVersion: v1
kind: Pod
metadata:
name: james-java
namespace: james
labels:
name: james-java
spec:
containers:
- name: james-java
image: 192.168.0.252/james/java:v1.0.1
ports:
- containerPort: 7102
env: # 添加
- name: TZ # 添加
value: Asia/Shanghai # 添加
制作docker镜像时候添加
# 拷贝到当前目录
cp /usr/share/zoneinfo/Asia/Shanghai ./localtime
vim timezone
Asia/Shanghai
# 修改dockerfile
FROM 192.168.0.252/szlaozi/java:8u111
MAINTAINER james.liu <liudongliang@szlaozi.com>
RUN mkdir /ENV/Microservice/ -p
... ...
ADD localtime /etc/localtime # 添加
ADD timezone /etc/timezone # 添加
EXPOSE 7103
WORKDIR /ENV/Microservice/
... ...
通过挂载本地文件实现
apiVersion: v1
kind: Pod
metadata:
name: james-java
namespace: james
labels:
name: james-java
spec:
containers:
- name: james-java
image: 192.168.0.252/szlaozi/java:v0.0.1
volumeMounts:
- name: tz-config
mountPath: /etc/localtime
ports:
- containerPort: 7102
volumes:
- name: tz-config
hostPath:
path: /etc/localtime
网友评论