mosquitto
mosquitto copied to clipboard
docker image does not recognise timezone appropriately
Description
Date on host reports according to timezone. Date on container reports in UTC.
Configuration
- 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
- Run compose file using
docker compose up --detach
Reproducing Issue
- Ensure the container is running
- Issue the following commands:
$ docker exec mqtt date
Tue Apr 16 15:35:43 UTC 2024
$ docker exec mqtt cat /etc/timezone
America/Edmonton
- 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.
adding tzdata package should be the best way to fix this, then we can just add the TZ: "Europe/Amsterdam" environment variable
See pull #3018. Hopefully someone will merge it one day.