containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.08k stars 2.35k forks source link

"/etc/zoneinfo/local: No such file" after creating a container with --tz local #23550

Open vivienne-w opened 1 month ago

vivienne-w commented 1 month ago

Issue Description

When creating a container on NixOS with --tz local, it later fails to start with this error:

Error: unable to start container "73dff85a07f82a43733f8685b561e4b175c282de8d6355ee433ab65c025088a8": configuring timezone for container 73dff85a07f82a43733f8685b561e4b175c282de8d6355ee433ab65c025088a8: setting timezone for container 73dff85a07f82a43733f8685b561e4b175c282de8d6355ee433ab65c025088a8: stat /etc/zoneinfo/local: no such file or directory

Steps to reproduce the issue

  1. podman create --tz local --name test debian
  2. podman start test

Describe the results you received

Error: unable to start container "73dff85a07f82a43733f8685b561e4b175c282de8d6355ee433ab65c025088a8": configuring timezone for container 73dff85a07f82a43733f8685b561e4b175c282de8d6355ee433ab65c025088a8: setting timezone for container 73dff85a07f82a43733f8685b561e4b175c282de8d6355ee433ab65c025088a8: stat /etc/zoneinfo/local: no such file or directory

Describe the results you expected

The container starts normally, with the correct timezone configured.

podman info output

host:
  arch: amd64
  buildahVersion: 1.37.0
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: Unknown
    path: /nix/store/3azk5pxlxzdmsif5qnr0agy1rgp73qd7-podman-helper-binary-wrapper/bin/conmon
    version: 'conmon version 2.1.12, commit: '
  cpuUtilization:
    idlePercent: 98.92
    systemPercent: 0.21
    userPercent: 0.87
  cpus: 64
  databaseBackend: sqlite
  distribution:
    codename: vicuna
    distribution: nixos
    version: "24.11"
  eventLogger: journald
  freeLocks: 2024
  hostname: tomato
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 100
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.6.35
  linkmode: dynamic
  logDriver: journald
  memFree: 173756747776
  memTotal: 202666819584
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: Unknown
      path: /nix/store/2imm3vch2vf0r1b4y4rzwh5qs50yq3p8-podman-5.2.0/libexec/podman/aardvark-dns
      version: aardvark-dns 1.12.0
    package: Unknown
    path: /nix/store/2imm3vch2vf0r1b4y4rzwh5qs50yq3p8-podman-5.2.0/libexec/podman/netavark
    version: netavark 1.7.0
  ociRuntime:
    name: crun
    package: Unknown
    path: /nix/store/3azk5pxlxzdmsif5qnr0agy1rgp73qd7-podman-helper-binary-wrapper/bin/crun
    version: |-
      crun version 1.15
      commit: 1.15
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /nix/store/2imm3vch2vf0r1b4y4rzwh5qs50yq3p8-podman-5.2.0/libexec/podman/pasta
    package: Unknown
    version: |
      pasta 2024_06_24.1ee2eca
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: ""
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /nix/store/2imm3vch2vf0r1b4y4rzwh5qs50yq3p8-podman-5.2.0/libexec/podman/slirp4netns
    package: Unknown
    version: |-
      slirp4netns version 1.3.1
      commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236
      libslirp: 4.8.0
      SLIRP_CONFIG_VERSION_MAX: 5
      libseccomp: 2.5.5
  swapFree: 0
  swapTotal: 0
  uptime: 5h 56m 29.00s (Approximately 0.21 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /home/vivienne/.config/containers/storage.conf
  containerStore:
    number: 3
    paused: 0
    running: 0
    stopped: 3
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/vivienne/.local/share/containers/storage
  graphRootAllocated: 1000190722048
  graphRootUsed: 243351670784
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /tmp
  imageStore:
    number: 47
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/vivienne/.local/share/containers/storage/volumes
version:
  APIVersion: 5.2.0
  Built: 315532800
  BuiltTime: Tue Jan  1 01:00:00 1980
  GitCommit: ""
  GoVersion: go1.22.5
  Os: linux
  OsArch: linux/amd64
  Version: 5.2.0

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

OS: NixOS

❯ echo $TZDIR 
/etc/zoneinfo

❯ ls -l /etc/localtime                   
lrwxrwxrwx - root  8 Aug 14:47 /etc/localtime -> /etc/zoneinfo/Europe/Berlin

Additional information

I assume this issue is related to NixOS setting TZDIR.

vivienne-w commented 1 month ago

From what I can tell, the issue seems to stem from ConfigureContainerTimeZone:

https://github.com/containers/podman/blob/9007553a81608ce88be2e3d69ca2ff54f20842d8/vendor/github.com/containers/common/pkg/timezone/timezone.go#L26-L35

Since TZDIR is set on my system, it completely ignores that timezone is "local", and thus tries to look up etc/zoneinfo/local.

Since the fix looks simple enough, Id happily open a PR, if its alright to use the CI for running the tests.

Luap99 commented 1 month ago

PR are welcome, note that the code you linked is in c/common so the fix must be submitted there first then we can update the dependency in podman once this is merged there.

I guess swapping both cases will make it work.

Luap99 commented 1 week ago

@vivienne-w I see commit here linked, are you going to open a PR in c/common?