That's the reason why I need to use apt-get update and apt-get install -yq tzdata firstly on my Dockerfile when using the Ubuntu 20.04 for my Docker base image.
Of course, we can simplify my Dockerfile when using the Ubuntu to be the Docker base image:
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install -yq tzdata
ENV TZ="Asia/Taipei"
Hmm, you are right, just tried
FROM debian:10, theENV TZway works. Seems just not working for ubuntu. Thank you for pointing out. TIL.If using the
ENVto set TZ to set the timezone, it should have thetzdatapackage installed on Linux distribution Docker base image.After investigating some common Linux distributions, the Debian and CentOS have the
tzdatainstalled on their Base Docker images.And Ubuntu doesn't have the
tzdatapackage on the Docker base image.That's the reason why I need to use
apt-get updateandapt-get install -yq tzdatafirstly on myDockerfilewhen using theUbuntu 20.04for my Docker base image.Of course, we can simplify my
Dockerfilewhen using theUbuntuto be the Docker base image:Got it, thanks for the awesome explanation. 👍