Skip to content

Fix Timezone Handling for Containers#375

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

Fix Timezone Handling for Containers#375
LSI-ZuagrastaWastl wants to merge 7 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 ?

Updated PHP timezone configuration 
and added symlink for timezone for supervisord.
sed dosen´t use "?"  so PHP_TIMEZONE was setting in php.ini
PHP_TIMEZONE wasn`t in template.env and so most not in use.
TZ Variable the global Timezone variable in this Project
Removed timezone configuration from docker-compose.
With the "sed fix" in the entrypoint_fpm.sh, No need to mount a separate file now
@LSI-ZuagrastaWastl
Copy link
Author

@ostefano
I took another closer look at everything and found a few errors. PHP_TIMEZONE could never be set as default in .env and was never set due to syntax errors in the entrypoint_fpm.sh. I fixed the error and tied everything to TZ.

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