Different Timezone in Docker and Container

Hi there,
I’m running HA 0.180.9 in a Docker on Synology.

As you can see in the screenshot, the log files show different timezones.

The correct time is in the log file, the container is wrong and two hours behind.
I’ve tried many docker starts like these:

sudo docker run -id --name=home-assistant --restart=always -v /etc/TZ:/etc/timezone:ro -p 8123:8123 -e “TZ=Europe/Berlin” --net=host -v /volume1/docker/home-assistant:/config homeassistant/home-assistant:latest

sudo docker run -id --name=home-assistant --restart=always -v /etc/timezone:/etc/timezone:ro -p 8123:8123 -e “TZ=Europe/Berlin” --net=host -v /volume1/docker/home-assistant:/config homeassistant/home-assistant:latest
docker: Error response from daemon: Bind mount failed: ‘/etc/timezone’ does not exists.

All these starts have no effect. Still wrong. You could say it doesn’t matter here but the main problem is, that the data in the database is wrong, too.
I’m using MariaDB on Synology, but not I docker, I use the package. The Timezone in MariaDB is set to “System”.

Whenever I query for some data from HomeAssistant.states ´, I have to add the correct amount of hours compared to UTC-Time.
Really annoying.

Automations or trigger DO have the right time.

Any idea ?
Greetings,
Oliver

1 Like

I always mount the following in the docker run command (I actually use docker-compose):

/etc/localtime:/etc/localtime:ro

Hi, thanks for your reply.
I tried that as you proposed:


version: '3'

services:
  home-assistant:
    container_name: home-assistant          
    image: homeassistant/home-assistant:latest     
    ports:
      - 8123:8123
    volumes:
      - /volume1/docker/home-assistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped         
    network_mode: host

Still the same problem.
Notice that I didn’t set the TZ-Environment. But the issue is still the same.

“Interval + 2 hours” is the correct local time.

How can I make sure, that the etc/localtime does have the correct time ? When I do
cat localtime
after some rubbish:
CET-1CEST,M3.5.0,M10.5.0/3

But I am at Europe/Berlin which has at the moment UTC +2

Greetings,
Oliver

I set TZ=Australia/Melbourne in my docker environment. I have the correct timezone in the logs, and in the time_date sensor, but the times shown in the logbook and history displays seem to be in UTC not local time… is there a solution to this?

1 Like