我们在构建自己的 docker 镜像时, 系统默认一般为 UTC, 我们需要改为 CST
Ubuntu16.04 基础镜像:
- FROM Ubuntu:16.04
- MAINTAINER [email protected]
- RUN ln -sf /usr/share/zoneinfo/Asia/ShangHai /etc/localtime
- RUN echo "Asia/Shanghai"> /etc/timezone
- RUN dpkg-reconfigure -f noninteractive tzdata
Alpine3.6 基础镜像:
- FROM alpine3.6
- MAINTAINER [email protected]
- RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
- RUN apk add --no-cache tzdata 5 && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 6 && echo "Asia/Shanghai"> /etc/timezone 7 &&rm -rf /var/cache/apk/*/tmp/*/var/tmp/* $HOME/.cache
来源: http://www.bubuko.com/infodetail-3156140.html