Docker Timezone in Ubuntu 16.04 Image

前端 未结 10 1769
借酒劲吻你
借酒劲吻你 2020-12-13 10:40

I have created a Docker container using the Ubuntu 16.04 image.

docker run -it -d --name containername -v /var/www/public --privileged ubuntu
10条回答
  •  臣服心动
    2020-12-13 11:00

    I am also experiencing this issue for a Ubuntu 18.04 docker container. Since tzdata package is not installed. There is no /usr/share/zoneinfo dir inside the docker. We need to first install tzdata and use dpkg-reconfigure to set the timezone. The following docker command works for me:

    ENV DEBIAN_FRONTEND=noninteractive
    RUN apt-get update && apt-get install -y --no-install-recommends tzdata \
        && rm -rf /var/lib/apt/lists/*
    RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
        && dpkg-reconfigure --frontend noninteractive tzdata
    

提交回复
热议问题