How to set timezone in matlab runtime docker container?

I'm having some trouble setting the timezone in a compiled Docker image.
How to reproduce the problem:
  1. run the matlab runtime image: docker run --rm -it -e TZ=Asia/Singapore --name mlrt --entrypoint bash matlabruntime/r2024b/release/update0/f00040001040000002
  2. within the container, running date +'%:z %Z' returns +00:00 Asia when I'm expecting +08:00
What I've tried
Since the base image claims to be based on Ubuntu: https://www.mathworks.com/help/compiler/get-matlab-runtime-container.html
I have tried but failed:
  1. Setting the TZ environment variable; this usually works for other Ubuntu-based containers.
  2. timedatectl doesn't work. Source: https://manpages.ubuntu.com/manpages/trusty/en/man1/timedatectl.1.html
Does anyone know how to set it to the correct timezone or could point me to the documentation?
Thanks.

 採用された回答

Calvin Lian
Calvin Lian 2024 年 10 月 23 日
編集済み: Calvin Lian 2024 年 10 月 23 日

0 投票

Here's the response from my local MATLAB distributor that solved the issue for me:
The base Ubuntu image provided does not include the tzdata package. This is needed for correct identification of timezones. There are 2 ways to solve this: it can be installed after the image is built, or during the the build process.
  • For the former, execute this in the container:
apt-get update && apt-get install tzdata -y

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2024 年 10 月 18 日

編集済み:

2024 年 10 月 23 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by