Search Icon, Magnifying Glass

Marmanold.com

Graduation Cap Heart Question Mark Magnifying Glass

Use Localtime in Debian Slim

Sometimes you need to run cron or other applications in your Debian container that rely on the system running in localtime. In Debian 9, switching to localtime wasn’t the easiest thing in the world. With Debian 10, however, you can switch your container to another timezone with just a few commands.

  1. First you need to install tzdata.

    RUN apt-get install tzdata -y
    
  2. Then you need to make a link between the timezone you want to move to in /usr/share/zoneinfo and /etc/localtime.

    RUN ln -sf /usr/share/zoneinfo/US/Central /etc/localtime
    
  3. Finally, you reconfigure tzdata to use your newly selected timezone.

    RUN echo "US/Central" | tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata