Tip & Trick #1: How to change timezone in a Linux Alpine container.

Tips & Tricks Apr 15, 2020

In this first tip & trick, 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 the visitors of this blog and their Spanish version focus on privacy. From the settings of this new solution we can't change the timezone, so, I needed to change to the container.

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" 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 do.

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

To confirm that was successfully, 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.

Ignacio Van Droogenbroeck

Hi. I'm always learning new things and share about it in this blog. This is my first experience writing in english, if you found a error, leave me a comment and help me to improve my english.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.