mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

docker image does not recognise timezone appropriately

Open instantdreams opened this issue 1 year ago • 1 comments

Description

Date on host reports according to timezone. Date on container reports in UTC.

Configuration

  1. Create a mosquitto compose.yaml file:
compose.yaml

services:
  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mqtt
    hostname: mqtt
    ports:
      - 1883:1883 # mqtt
      - 9001:9001 # websockets
    environment:
      - TZ=America/Edmonton
    volumes:
      - /srv/mqtt/config:/mosquitto/config
      - /srv/mqtt/data:/mosquitto/data
      - /srv/mqtt/log:/mosquitto/log
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
  1. Run compose file using docker compose up --detach

Reproducing Issue

  1. Ensure the container is running
  2. Issue the following commands:
$ docker exec mqtt date
Tue Apr 16 15:35:43 UTC 2024
$ docker exec mqtt cat /etc/timezone
America/Edmonton
  1. Confirm container is running successfully

Environment

  • Docker Compose version v2.24.7
  • Docker version 25.0.4, build 1a576c5
  • mosquitto version 2.0.18

Expectation

To rebuild the mqtt docker container to include the tzdata component so it is timezone aware, or to implement another process to support timezones.

instantdreams avatar Apr 16 '24 15:04 instantdreams

adding tzdata package should be the best way to fix this, then we can just add the TZ: "Europe/Amsterdam" environment variable

Ruvetuve avatar Aug 07 '24 10:08 Ruvetuve

See pull #3018. Hopefully someone will merge it one day.

ajaypala avatar Sep 29 '24 10:09 ajaypala