Rahasak Labs
Published in

Rahasak Labs

Docker timezone configuration in Linux

Happy devOps


By default, Linux and Docker use UTC timezone. We need to manually configure the timezone in these environments. In this post I’m gonna discuss about configuring Linux and Docker container timezones. All the source codes which related to this post available in gitlab. Please clone the repo and container the post.

Linux timezone

We can configure the Linux timezone with timedatectl command. Following is the way to do that. Changing Linux machine timezone does not affects to the Docker containers timezone. We need to manually configure the timezone in Docker containers.

Docker timezone

In order to set the timezone in Docker container we can set the TZ environment variable with the timezone inside the Docker container. To use the TZ environment variable we need to install the tzdata package in docker container. Here I have dockerized a golang based REST API with installing tzdata package. Following is the Dockerfile.

When running the service I need to set the TZ environment variable value with the timezone. Following is the way to set it with docker-compose.yml.

If we run the service without setting TZ variable docker will use default UTC timzone. After setting the TZ and restart the service it will use the given timezone.


  1. https://medium.com/developer-space/be-careful-while-playing-docker-about-timezone-configuration-e7a2217e9b76
  2. https://linuxacademy.com/blog/linux/changing-the-time-zone-in-linux-command-line/
  3. https://linuxize.com/post/how-to-set-or-change-timezone-in-linux/
  4. https://www.tecmint.com/set-time-timezone-and-synchronize-time-using-timedatectl-command/




Have less, be more

Recommended from Medium

3 Essential Tips for Interviewing Software Engineers

Females in a meeting

Fun With HTML Canvas — Build the Matrix

CentOS 8: Install vsftpd (ftp server)

Docker Container on Azure Functions with Python

Upskilling Test Engineers for Chatbot Projects

Code solution with no GUI involvement and 100% complete automation

How To Create Secure Firestore Rules For Your Firebase Application

Partition List

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Ego = 1/Knowledge

More from Medium

Kubernetes, for software developers (part 3)

Learn Kubernetes: Deploy a mysql DB

Software-only High Availability and Load Balancing for your Kubernetes API

Getting Started with Kubernetes (K8s) -Part 1