ubuntu 18.04修改时区

apt update 
apt install tzdata --no-install-recommends #最小安装

echo "Asia/Shanghai" > /etc/timezone
ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
dpkg-reconfigure -f noninteractive tzdata  #使用时区生效

#cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#rm -f /etc/localtime
#dpkg-reconfigure tzdata

Dockerfile

ENV DEBIAN_FRONTEND noninteractive #tzdata 静默认安装

RUN apt-get update \
  &&  apt install -y tzdata --no-install-recommends \
  &&  echo "Asia/Shanghai" > /etc/timezone  \
  && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  && dpkg-reconfigure -f noninteractive tzdata