Sunday, 13 February 2022

Linux Ubuntu Docker install tzdata non interactive

 Problem

     Default Ubunt image from Docker does not come with Timezone data.  Installation of the package prompts for input, and this can be problematic for automated installation. This also cause issue when installing Python 3.9 on Docker image.

Solution

Create Timezone file and /etc/localtime link prior to installation 

 



javascript
apt update echo "Europe/London" > /etc/timezone ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime apt install -y tzdata

Docker Install Python3.9 non interactive

Summary 

Python3.9 is available as package distribution for ubuntu, however it can often be a challenge to install it interactively on Ubunt Docker image. This is because Timezone data (tzdata) is not installed and it prompts for Timezone information. 

Installing Python3.9 and Pip Nomal

apache
apt update ; apt install -y python3.9 python3-pip Installing Python 3.9 with TimeZone non-interactively

Installing Python 3.9 with TimeZone non-interactively

python
apt update #Setup Timezone package. Not installed by default on Ubuntu, and will cause prompt when trying to install python 3.9 echo "Europe/London" > /etc/timezone ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime apt install -y tzdata #Install required version of Python. installed in /usr/bin apt install -y python3.9 python3-pip #Pip3 creates a link called python3 in /usr/bin This link determines which Python3 it works with. So repoint it to version required. [[ -f /usr/bin/python3 ]] && rm -f /usr/bin/python3 #Linking python3 to python3.9 ln -s /usr/bin/python3.9 /usr/bin/python3