Docker-selenium: Can't set timezone in container

Created on 12 Jun 2015  路  6Comments  路  Source: SeleniumHQ/docker-selenium

We're running into timezone issues because the docker-selenium containers have a different timezone than our host has. This is mostly due to this line in the Dockerfile:
https://github.com/SeleniumHQ/docker-selenium/blob/52233f089aeec8c24d047a5a932d3c9e40d979c2/NodeBase/Dockerfile#L11

We can fix /etc/timezone and /etc/localtime by running the container with: -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:r, but that doesn't allow us to overwrite the TZ env var. This results in tools like date and Firefox still using the US/Pacific timezone.

I-all help wanted

Most helpful comment

I found out that I could fix this by doing docker run -e TZ="Europe/Amsterdam". Maybe this should be added to the docs? Because it seems a non-standard way of setting timezone for a container.

All 6 comments

I found out that I could fix this by doing docker run -e TZ="Europe/Amsterdam". Maybe this should be added to the docs? Because it seems a non-standard way of setting timezone for a container.

the NodeBase has TZ set which means it will propagate to all the Nodes (however Hub doesn't get TZ set so booo... we can fix it by moving TZ setting to Base image).

A case could be made to chagne TZ to be Zulu and operate on UTC for all.

And yes, when you docker run add the TZ you need with -e TZ="<your tz>"

So I vote on 2 things:

  1. move TZ to Base Docker file so Hub gets it
  2. set TZ to utc timezone as universal

thoughts?

Recently I ran into this issue and used the docker run -e TZ="< >" as well.
What sort of help is required to fix this ?

agreed, @rubytester, both points. making those changes now.

also wrote a quick'n'simple wiki to using it: https://github.com/SeleniumHQ/docker-selenium/wiki/Setting-a-Timezone

Long back, got this fixed and added it to Leo's repo and not here. Should have added here too.
https://github.com/elgalu/docker-selenium/commit/767bdd644ab3cd07e4f59a4b62528bd8e817f35c

Was this page helpful?
0 / 5 - 0 ratings