Skip to content

Grafana bridge container time different from host time

hwassman edited this page Jan 15, 2025 · 1 revision

Grafana-bridge container time is 1 hour behind the host time

# date
Mon Jan 13 09:39:08 PM CET 2025

# podman ps
CONTAINER ID  IMAGE                                    COMMAND               CREATED            STATUS            PORTS                                           NAMES
b8910c688b15  localhost/podman-pause:4.4.1-1676978277                        About an hour ago  Up About an hour  0.0.0.0:4242->4242/tcp, 0.0.0.0:9250->9250/tcp  9391f1192121-infra
977ac01c1de0  localhost/scale_bridge:test_8.0.2_prod   sh -c python3 zim...  About an hour ago  Up About an hour  0.0.0.0:4242->4242/tcp, 0.0.0.0:9250->9250/tcp  bridge-basic-auth-test
346a57e23572  localhost/podman-pause:4.4.1-1676978277                        30 seconds ago     Up 29 seconds     0.0.0.0:4243->4242/tcp, 0.0.0.0:9251->9250/tcp  3b33f10f785b-infra
7b39b67fa0d0  localhost/scale_bridge_arg:1.0_dev       sh -c python zimo...  29 seconds ago     Up 29 seconds     0.0.0.0:4243->4242/tcp, 0.0.0.0:9251->9250/tcp  bridge-python-test

# podman exec -it 7b39b67fa0d0 /bin/bash
(app-root) bash-5.1# date
Mon Jan 13 08:41:16 PM UTC 2025

When container engines like Podman, Docker, or CRI-O run containers, they pull down the specified OCI image from a container registry. This image is built with a hardcoded link from /etc/localtime to one time zone. Usually, the time zone is set to the location where the image or base image was built, or to UTC±00:00 For more information, read the Readhat article Does your container know what time it is?

Solution

There are 2 ways you can fix this problem

  1. Sync time by mounting the time zone file from the host into the container.

See 'podman run' command documentation for [--tz] (https://docs.podman.io/en/stable/markdown/podman-run.1.html#tz-timezone)

#  podman run -dt -p 4243:4242,9251:9250 -e "SERVER=9.152.187.254" -e "APIKEYVALUE=54dc249a-6de2-4399-bec0-6155f35ff3c7" -e "PORT=4242" -e "PROMETHEUS=9250" -e "BASICAUTHUSER=scale_admin" -e "BASICAUTHPASSW=TXlWZXJ5U3Ryb25nUGFzc3cwcmQhCg==" -e "LOGLEVEL=5" -v /templog:/var/log/ibm_bridge_for_grafana --mount type=bind,src=/home/zimon/ZIMonSensors.cfg,target=/opt/IBM/zimon/ZIMonSensors.cfg,ro=true --tz CET --pod new:my-test-pod --name bridge-python-test scale_bridge_arg:1.0_dev
5121276ce494b68a49131817b7829f68701f992ffa081ac6f31f30c365778517


# podman ps
CONTAINER ID  IMAGE                                    COMMAND               CREATED            STATUS            PORTS                                           NAMES
b8910c688b15  localhost/podman-pause:4.4.1-1676978277                        About an hour ago  Up About an hour  0.0.0.0:4242->4242/tcp, 0.0.0.0:9250->9250/tcp  9391f1192121-infra
977ac01c1de0  localhost/scale_bridge:test_8.0.2_prod   sh -c python3 zim...  About an hour ago  Up About an hour  0.0.0.0:4242->4242/tcp, 0.0.0.0:9250->9250/tcp  bridge-basic-auth-test
cfc6695d2ea1  localhost/podman-pause:4.4.1-1676978277                        2 minutes ago      Up 2 minutes      0.0.0.0:4243->4242/tcp, 0.0.0.0:9251->9250/tcp  b8b869f6a80f-infra
5121276ce494  localhost/scale_bridge_arg:1.0_dev       sh -c python zimo...  2 minutes ago      Up 2 minutes      0.0.0.0:4243->4242/tcp, 0.0.0.0:9251->9250/tcp  bridge-python-test

# podman exec -it 5121276ce494 /bin/bash
(app-root) bash-5.1# date
Mon Jan 13 09:46:10 PM CET 2025
  1. Set a system-wide default timezone for all your containers using containers.conf.

Step-by-step instructions are described in the Readhat article Does your container know what time it is?

User Guide

Installation

Configuration

Maintenance

Troubleshooting

Use cases

Designing dashboards

Developer Guide

Clone this wiki locally