Fix: tzdata hangs during Docker image build

Grigor Khachatryan
2 min readAug 4, 2020

--

During the installation of a few packages, Ubuntu usually installs the tzdata package. It’s usually included in some PHP or Python packages dependencies. The issue with it is that it hangs and waits for user input to continue the installation. It’s ok until we are using Docker and trying to build images (it’s hanging or even throwing errors in newer versions of Ubuntu). We will try to reproduce the situation and try to fix it.

To reproduce the hanging situation, we can use this Docker image:

Here is the logs that we see in terminal:

And here it hangs waiting for us enter data, and even after you’ll enter a region — the process will not resume.

To fix this situation we need to add lines 3 and 4 to our Dockerfile. We will create a variable called $TZ which will hold our timezone, and the create a /etc/timezone file:

And after building image we will see this output:

So it’s used the timezone that we provide and nothing hangs.

Here is the list of Timezones that you can pick one for you:

Like to learn?

Follow me on twitter where I post all about the latest and greatest AI, DevOps, VR/AR, Technology, and Science! Connect with me on LinkedIn too!

--

--

Responses (1)