rfay
rfay

Reputation: 12935

How can I set the timezone in my ddev containers?

I often use ddev ssh (for web/nginx container) or ddev ssh -s db (for the db/mariadb container), and when looking at logs and such I'd like to see date/timestamps in my own timezone so I don't have to think so hard about how many hours it is from GMT. I can't use dpkg-reconfigure tzdata in the container because the container user doesn't have root privileges.

Upvotes: 0

Views: 3452

Answers (2)

rfay
rfay

Reputation: 12935

Edit 2025-01-03: In recent versions of DDEV, the timezone is inferred from the host-side timezone automatically for most situations, but setting the timezone as below is still a valid approach. See docs.

Configure this in the .ddev/config.yaml: timezone: Europe/London, for example, or ddev config --timezone=Europe/London This configures both the container's timezone and php's default timezone.**

See https://ddev.readthedocs.io/en/stable/users/configuration/config/#timezone

Upvotes: 6

rfay
rfay

Reputation: 12935

As of ddev v1.8.0, you can also set the timezone in the web container by configuring .ddev/webimage-build/Dockerfile. In fact, the .ddev/webimage-build/Dockerfile.example does exactly this:

ARG BASE_IMAGE=drud/ddev-webserver:v1.8.0
FROM $BASE_IMAGE
RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && dpkg-reconfigure --frontend noninteractive tzdata

As above, you'd also want a PHP override in .ddev/php/tz.ini,

date.timezone = Europe/Berlin

Upvotes: 1

Related Questions