Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to podman run/create to automatically set the timezone in container to match host. #5128

Closed
rhatdan opened this issue Feb 7, 2020 · 21 comments · Fixed by #6836
Closed
Assignees
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue

Comments

@rhatdan
Copy link
Member

rhatdan commented Feb 7, 2020

Something like?
--tz host
--tz image

Then in containers conf, we could allow setting this by default.

Thoughts?

@vrothberg
Copy link
Member

Sounds great (also getting it into the containers.conf). I prefer a longer --timezone flag.

@TomSweeneyRedHat
Copy link
Member

I don't know, tz == twilight zone right? I like the idea, but prefer the longer option. I'd be fine if we allowed both though.

@mheon
Copy link
Member

mheon commented Feb 7, 2020

I think the acronym is pretty well established, so I doubt we run into conflicts. My only question is how much work is involved - is this just an extra file to make and mount into the container, like resolv.conf? Does it differ at all between distros?

@rhatdan
Copy link
Member Author

rhatdan commented Feb 7, 2020

I have similar concerns. It could be just injecting the hosts TZ Environment, but copying the contents of /etc/localtime into container private data might be required as well.

@baude
Copy link
Member

baude commented Feb 8, 2020

is the idea here that by default this would be false or true?

@mheon
Copy link
Member

mheon commented Feb 8, 2020 via email

@rhatdan
Copy link
Member Author

rhatdan commented Feb 10, 2020

Yes, false by default, but customizable in containers.conf.

@edsantiago
Copy link
Member

One snag to be aware of: there are three scenarios here, not two:

  • --tz=image - does nothing
  • --tz=host - (presumably) bind-mounts /etc/localtime. This should be easy.
  • --tz=user? - this is the case where the user has TZ explicitly set, overriding system /etc/localtime. This is, I believe, thorny.

podman could simply env-forward TZ, but that could yield unexpected results: e.g. alpine does not have /usr/share/zoneinfo, so time zone handling will be different from the host.

Another option is, if TZ is defined, have podman check if /usr/share/zoneinfo/$TZ exists, then bind-mount that as the container's /etc/localtime. First obvious caveat is that podman will have to be careful about path traversals (TZ=../../../dev/mem)

@edsantiago
Copy link
Member

Groan. The obvious next step is that someone will want --tz=STRING, e.g. US/Eastern or EST5EDT or somesuch. This escalates quickly.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 18, 2020

Sure, but I think we just keep it simple and mount the file pointed to by /etc/localtime into the container.

@psychic-toaster
Copy link

psychic-toaster commented Feb 18, 2020

Suggest to avoid adding ambiguity, use 2 facets.

Contact timeserver, save in UTC
if no TServer avail, use /etc/localtime, but put F in front of the timezone. (I'm in EST, so my files would show modify times of FEST)

Here's why --
Contact a timeserver, and obtain UTC, then just store it in UTC [ removes cloud host "where in cloud was this done" part as well as gives the filesystem and investigators 'one truth' about change time] stops colleagues in Sydney modifying files in the 'future' and me from modifying files EST at same (or similar times in same day localtime, yet in 'real time' should be 16 hr later)
if no Timeserver avail then use local time, and mark timezone as "FEST" -- (stands for Forced Local EST as I pointed out above)
This flags to person investigating change's birth time -- "hey! timestamp is biased by whatever and whereever user created it"

@rhatdan
Copy link
Member Author

rhatdan commented Feb 18, 2020

@sspoddiglane would you like to attempt to create a PR for this?

/etc/localtime on my box is a binary file.

@psychic-toaster
Copy link

psychic-toaster commented Feb 21, 2020 via email

@rhatdan
Copy link
Member Author

rhatdan commented Feb 21, 2020

Awesome. Just a PR to github, if that is what you meant?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member Author

rhatdan commented Mar 23, 2020

@sspoddiglane Any movement on this, or should I look for someone else?

@psychic-toaster
Copy link

psychic-toaster commented Apr 3, 2020 via email

@rhatdan
Copy link
Member Author

rhatdan commented Jun 9, 2020

@sspoddiglane Any movement on this?

@rhatdan
Copy link
Member Author

rhatdan commented Jun 9, 2020

@ashley-cui Want to take a look at this?

@dougsland
Copy link
Contributor

@rhatdan

Hi,

Are you looking for something like?

Flags:

<snip>
--timezone-host                 Bind mount /etc/localtime from the underlying host
<snip>

@rhatdan
Copy link
Member Author

rhatdan commented Jun 22, 2020

I am actually thinking of both. Basically set the TZ Environment if not set and mount the /etc/localtime mountpoint into the container.
But this should also be wired into containers.conf so that this can be set to true on the system for all containers.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants