Pique #22: How to change timezone in a Linux Alpine container

In this first Pique (Tip & Trick) in English, I will show you how to change the timezone in a Linux Alpine Docker container.


1 min de lectura
Pique #22: How to change timezone in a Linux Alpine container

In this first Pique (Tip & Trick) in English, I will show you how to change the timezone in a Linux Alpine Docker container.

These days, I'm trying a new system to track this blog's visitors, but the problem with this solution, by default, shows the time in UTC, and I need to change to fit my current timezone (-3).

If you ask, Don't have an option in the UI to do this change.

Investigating a little, I realize that the way to get the time in another timezone in this software is changing the container's timezone.

To do that, first, we need to enter to the container:

$ docker exec -it <id-container> ash

Then, we need to install "tzdata". We can do this typing the following:

$ apk add tzdata

Once "tzdata" it's installed, let's explore the next folder:

$ cd /usr/share/zoneinfo

We need to find the region and the zone and when we found, only need to copy to /etc/localtime. In my case, this is how I did.

$ cp /usr/share/zoneinfo/America/Montevideo /etc/localtime

To confirm that was successful, we only need to run the command date.

$ Tue Apr 14 11:41:02 -03 2020

That's all. Let me know if you have any questions.


baehost

SUBIR

🎉 Te has suscrito con éxito a CDUser - El Blog de Ignacio Van Droogenbroeck!
OK