Docker Timezone in Ubuntu 16.04 Image

前端 未结 10 1742
借酒劲吻你
借酒劲吻你 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:01

    Simply map the volume while running docker container

    -v /etc/timezone:/etc/timezone:ro

    0 讨论(0)
  • 2020-12-13 11:05

    Try:

    echo "Asia/Kolkata" > /etc/timezone
    rm -f /etc/localtime
    dpkg-reconfigure -f noninteractive tzdata
    

    You have to do rm /etc/localtime because of the Ubuntu bug.

    0 讨论(0)
  • 2020-12-13 11:08

    Updating /etc/timezone is the usual way, but there's a bug in Xenial which means that doesn't work.

    Instead you need to create a link from the desired timezone to etc/localtime:

    FROM ubuntu:xenial     
    RUN ln -fs /usr/share/zoneinfo/US/Pacific-New /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
    
    0 讨论(0)
  • 2020-12-13 11:10

    SOLVED:

    FROM ubuntu:16.04
    
    RUN apt-get update && \
        apt-get install -y software-properties-common apt-utils locales tzdata
    
    RUN echo "tzdata tzdata/Areas select Europe" > timezone.txt
    RUN echo "tzdata tzdata/Zones/Europe select Rome" >> timezone.txt
    RUN debconf-set-selections timezone.txt
    RUN rm /etc/timezone
    RUN rm /etc/localtime
    RUN dpkg-reconfigure -f noninteractive tzdata
    
    0 讨论(0)
提交回复
热议问题