我们在构建自己的docker镜像时,系统默认一般为UTC,我们需要改为CST
Ubuntu16.04基础镜像:
1 FROM ubuntu:16.04 2 MAINTAINER xx@example 3 RUN ln -sf /usr/share/zoneinfo/Asia/ShangHai /etc/localtime 4 RUN echo "Asia/Shanghai" > /etc/timezone 5 RUN dpkg-reconfigure -f noninteractive tzdata
Alpine3.6基础镜像:
1 FROM alpine3.6 2 MAINTAINER xx@example.cn 3 RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories 4 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