[Error] /etc/localtime integration with the host failed, runtime sync for /etc/localtime disabled. Error: An error occurred
Describe the bug Fails to create an ubuntu 22.04 container after failing to bind mount /etc/localtime
To Reproduce
distrobox create -i ubuntu:22.04 -n ubuntu-test --init --home $HOME/containers/ubuntu-testdistrobox enter ubuntu-test
Expected behavior Container is successfully created
Logs
+ mount_bind /run/host/etc/localtime /etc/localtime ro
+ source_dir=/run/host/etc/localtime
+ target_dir=/etc/localtime
+ mount_flags=
+ [ 3 -gt 2 ]
+ mount_flags=ro
+ [ -L /run/host/etc/localtime ]
+ init_readlink /run/host/etc/localtime
+ ls -l /run/host/etc/localtime
+ grep -Eo \->.*
+ cut -d -f2-
+ sed s|\.\./|/|g
+ source_dir=/usr/share/zoneinfo/America/Chicago
+ printf %s /usr/share/zoneinfo/America/Chicago
+ grep -q /run/host
+ source_dir=/run/host/usr/share/zoneinfo/America/Chicago
+ [ ! -d /run/host/usr/share/zoneinfo/America/Chicago ]
+ [ ! -f /run/host/usr/share/zoneinfo/America/Chicago ]
+ [ -e /etc/localtime ]
+ findmnt /etc/localtime
+ [ -L /etc/localtime ]
+ rm -f /etc/localtime
+ [ -d /run/host/usr/share/zoneinfo/America/Chicago ]
+ [ -f /run/host/usr/share/zoneinfo/America/Chicago ]
+ dirname /etc/localtime
+ [ ! -d /etc ]
+ touch /etc/localtime
+ [ ro = ]
+ mount --rbind -o ro /run/host/usr/share/zoneinfo/America/Chicago /etc/localtime
mount: /etc/localtime: filesystem was mounted, but any subsequent operation failed: Unknown error 5005.
+ printf Warning: failed to bind mount %s to %s using option %s\n /run/host/usr/share/zoneinfo/America/Chicago /etc/localtime ro
Warning: failed to bind mount /run/host/usr/share/zoneinfo/America/Chicago to /etc/localtime using option ro
+ return 1
+ printf Warning: %s integration with the host failed, runtime sync for %s disabled.\n /etc/localtime /etc/localtime
Warning: /etc/localtime integration with the host failed, runtime sync for /etc/localtime disabled.
+ [ -f /run/host/etc/localtime ]
+ rm -f /etc/localtime
rm: cannot remove '/etc/localtime': Device or resource busy
+ [ 1 -ne 0 ]
+ printf Error: An error occurred\n
Error: An error occurred
time="2024-12-01T23:52:32-06:00" level=debug msg="Called logs.PersistentPostRunE(podman --log-level debug logs ubuntu-intune)"
time="2024-12-01T23:52:32-06:00" level=debug msg="Shutting down engines"
time="2024-12-01T23:52:32-06:00" level=info msg="Received shutdown.Stop(), terminating!" PID=47893
Full log (and podman log) is attached. podman.log distrobox.log
Desktop (please complete the following information):
- Are you using podman, docker or lilipod?
- podman
- Which version or podman, docker or lilipod?
- podman version 5.3.1
- Which version of distrobox?
- distrobox: 1.8.0
- Which host distribution?
- KDE Linux (based on Arch Linux)
- How did you install distrobox?
- pacman (arch repos)
Additional context
as far as I can tell, my /etc/localtime is just a regular symlink pointing to /usr/share/zoneinfo/America/Chicago
Okay, I figured out the issue.
https://github.com/89luca89/distrobox/blob/18053c254a83750c49c08e58df2e48a0f04aef48/distrobox-init#L268-L306
get_locked_mount_flags checks if there are any flags that need to be passed to the bind mount for the file. However, if the file is a symlink the the flags of the destination must also be checked and passed. It doesn't currently handle this case.
PR incoming.
This still appears to be a problem, running Distrobox 1.8.1.2 on Debian 12 with Podman 4.3.1.
It can be reproduced by creating a Debian 13 (currently testing) toolbox.
Installing or upgrading tzdata (which happens on first enter) fails to delete /etc/localtime.
Edit: Spoke to soon. It can be worked around by distrobox enter again, then I guess don't update the tzdata package.