Change default timezone of a docker containe

Lakshani Gamage
Jan 27, 2022

--

Build the Docker image using the below file.

  1. Create a file called “Dockerfile”. Content should be like below. Here BASE_IMAGE should be give as a user input.
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
USER root
RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Phnom_Penh /etc/localtime \
&& echo "Asia/Phnom_Penh" > /etc/timezone

2. Execute the below command. Here -f Dockerfile is the above docker file.

You can build the docker image using,

docker build -t <expected-image-name> -f Dockerfile — build-arg BASE_IMAGE=<base image>

ex:-

docker build -t wso2.abc:8123/wso2am-tc:4.0.0.66 -f Dockerfile — build-arg BASE_IMAGE=test.com:8123/wso2am:4.0.0.66 .

After executing the above command, wso2.abc:8123/wso2am-tc:4.0.0.66 image is creating with the updated timezone configuration.

--

--

Lakshani Gamage
Lakshani Gamage

Written by Lakshani Gamage

I am Lakshani Gamage, a post graduate from the University of Colombo, School of Computer. I’m working as a Senior Software Engineer at Mitra Innovation.

No responses yet