docker时区问题-处理方法
1、docker时区问题
- 1 运行时加参数
docker run -e TZ="Asia/Shanghai"
- 2 挂载时区文件
docker run -v /etc/localtime:/etc/localtime
- 3 dockerfile文件
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai'>/etc/timezone
2、docker-compose时区问题-方法
version: '3.1'
services:
verdaccio:
image: verdaccio/verdaccio:5.1.1
container_name: "verdaccio"
networks:
- node-network
environment:
- VERDACCIO_PORT=4873
- TZ=Asia/Shanghai ##时区
好像这个也可以
environment:
- SET_CONTAINER_TIMEZONE=true
- CONTAINER_TIMEZONE=Asia/Shanghai
3、k8s 时区问题-方法
1 挂载服务器的时区
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
namespace: default
labels:
app: my-pod
spec:
containers:
- name: my-pod
image: nginx
volumeMounts:
- name: host-time
mountPath: /etc/localtime
readOnly: true
volumes:
- name: host-time
hostPath:
path: /etc/localtime
2 传递变量
apiVersion: v1
kind: Pod
metadata:
name: pod-env-tz
spec:
containers:
- name: ngx-time
image: nginx:latest
env:
- name: TZ
value: Asia/Shanghai
3 修改基础映像的时区
----------当你发现自己的才华撑不起野心时,就请安静下来学习吧---------