The time in the docker container is inconsistent with the system time in linux (nginx:alpine image)
1. Background environment
- linux7.9
- Basic linux7.9 uses docker to pull the container of nginx:alpine image
2. Phenomenon
- linux system time
- container time
3. Solutions
The time zone in centos is a soft link
But in the alpine mirror container, there is no such file under etc
So specify the time zone file in the container
1、添加工具
apk update && apk add tzdata
2、创建时区文件
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
3、检查
date