Skip to content

Docker compose timezone bug #537

Description

@FrizbySVK

Hi, when running project with docker compose, timezone isn't evaluated correctly when backup is started.
Right now, I'm UTC+2 and backups are made at UTC time. So basically 2 hours later than I defined.

  • host timezone info (Europe/Bratislava) is mounted as readonly volume as per config reference
  • docker logs show the right time when debug is set to true. Same directly in the container. Time is correct
  • here's a snippet of my docker-compose.yml:
  db_backup:
    image: databack/mysql-backup:1.5.0
    container_name: "${CONTAINER_PREFIX}_db_backup"
    restart: always
    volumes:
      - ./_db_backup/dataBackup:/db
      - ./_db_backup/_dataImport:/dataImport
      - ./_db_backup/scriptC/pre-backup:/scripts.d/pre-backup
      - ./_db_backup/scriptC/post-backup:/scripts.d/post-backup
      - ./_db_backup/log:/var/log/db-backup
      # use host timezone info
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /usr/share/zoneinfo:/usr/share/zoneinfo:ro
    environment:
      - DB_SERVER=db
      - DB_PORT=3306
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASSWORD}
      - DB_DUMP_TARGET=/db
      - DB_DUMP_BEGIN=0400
      - DB_DUMP_FREQ=1440
      - DB_DUMP_INCLUDE=${DB_NAMES_BACKUP}
      - LOG=/var/log/db-backup/Cron__1d__0400__15min__backupDb.log
      - LOG_DETAIL=/var/log/db-backup/Cron_1d__backupDb_detail.log
      - LOG_ERROR=/var/log/db-backup/backupDb.error.log
      - DB_DEBUG=true
    working_dir: /db
    command: dump
    user: "0" #root
    depends_on:
      db:
        condition: service_healthy

Docker logs of the image when it's started (UTC+2 so it's correct:

time="2026-08-17T09:00:09+02:00" level=debug msg="starting dump"

Containter time:

0faca8e5b026:/db# date
Tue Aug 18 06:48:05 CEST 2026
0faca8e5b026:/db# cat /etc/timezone 
Europe/Bratislava

Only option is to rebuild the image with overridden Dockerfile like this:

FROM databack/mysql-backup:1.5.0

USER root

RUN apk update && apk add tzdata logrotate && \
  ln -s /usr/share/zoneinfo/Europe/Bratislava /etc/localtime

# original entrypoint
ENTRYPOINT ["/entrypoint"]

So if I do it like this, it works. Mounting timezone info directly in compose file is not working for the purposes of backup scheduling.

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions