mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Add --tz flag to create, run
--tz flag sets timezone inside container Can be set to IANA timezone as well as `local` to match host machine Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
@ -1525,6 +1525,30 @@ func withSetAnon() VolumeCreateOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithTimezone sets the timezone in the container
|
||||
func WithTimezone(path string) CtrCreateOption {
|
||||
return func(ctr *Container) error {
|
||||
if ctr.valid {
|
||||
return define.ErrCtrFinalized
|
||||
}
|
||||
if path != "local" {
|
||||
zone := filepath.Join("/usr/share/zoneinfo", path)
|
||||
|
||||
file, err := os.Stat(zone)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//We don't want to mount a timezone directory
|
||||
if file.IsDir() {
|
||||
return errors.New("Invalid timezone: is a directory")
|
||||
}
|
||||
}
|
||||
|
||||
ctr.config.Timezone = path
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Pod Creation Options
|
||||
|
||||
// WithPodName sets the name of the pod.
|
||||
|
Reference in New Issue
Block a user