Skip to content

Comments

Fix Timezone Handling for Containers#375

Open
LSI-ZuagrastaWastl wants to merge 3 commits intoMISP:masterfrom
LSI-Bayern:master
Open

Fix Timezone Handling for Containers#375
LSI-ZuagrastaWastl wants to merge 3 commits intoMISP:masterfrom
LSI-Bayern:master

Conversation

@LSI-ZuagrastaWastl
Copy link

This PR standardizes timezone handling across all MISP Docker containers.

The timezone can now be set optionally via the TZ environment variable.
If defined, it is applied globally and consistently across all containers and all processes, including system services, supervisord, background jobs, logs, and the MISP web interface.

If TZ is not set, the default remains UTC.

Changes

  • Added TZ as environment variable with default UTC
  • Mounted /usr/share/zoneinfo/${TZ:-UTC} to /etc/localtime
  • Configured PHP (tzone.ini) to use date.timezone from TZ

Benefits

  • Consistent timezone across system, logs, workers, and web interface
  • Optional but globally enforced configuration
  • More portable Docker setup
  • Non-breaking change

Best Regards from Bayern-CERT

Add timezone setting option to template.env
- Add timezone environment variable to all services
- Setting Default to "UTC"
- Add timezone configuration for PHP in docker-compose file.
- Replace PHP timezone in misp-core with the new config-file tzone.ini

Perhaps there are better solutions for changing the time zone from PHP during runtime.
retries: 3
start_period: 10s

configs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this to a separate file and edit Dockerfile to COPY it at build time and run sed in there (like we do with the PHP files?

Your solution is much cleaner, but not everybody is using docker-compose.yml.

Copy link
Author

@LSI-ZuagrastaWastl LSI-ZuagrastaWastl Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, I had primarily focused on the fact that when using docker-compose.yml, you have the option of setting the time zone everywhere. And as far as I can see, configs: must therefore remain in docker-compose.yml for the PHP-Settings.

As far as I can see, for the build-time is the timezone setting via ${PHP_TIMEZONE}.

sed -i "s/;?date.timezone = .*/date.timezone = ${PHP_TIMEZONE}/" "$FILE"

Therefore, in my opinion, no additional file would be necessary.
However, this variable has no effect on a finished image via docker-Compose.yml.

I could imagine that you could ensure that either ${PHP_TIMEZONE} or ${TZ:-UTC} is used. This means you only have to set it once in .env in example like this
sed -i "s/;?date.timezone = .*/date.timezone = ${PHP_TIMEZONE:-${TZ:-UTC}}/" "$FILE"

And probably here

ENV TZ=Etc/UTC

would be better ENV TZ= ${TZ:-UTC}.

What do you think about it @ostefano ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants