docker-mailserver: apt update error: tzdata

Discussed in https://github.com/docker-mailserver/docker-mailserver/discussions/2801

<div type='discussions-op-text'>

Originally posted by cociweb September 28, 2022 Hello,

I’ve tried to update the apt packages inside the docker image and the tzdata packages continously gives an error. I’ve recreated the container and the issue is the same. Maybe I do something wrong, with the timezone data and or env variables or it’s a general issue with the container?

apt upgrade

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  tzdata
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 284 kB of archives.
After this operation, 6144 B disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bullseye/main amd64 tzdata all 2021a-1+deb11u5 [284 kB]
Fetched 284 kB in 0s (956 kB/s)
Preconfiguring packages ...
(Reading database ... 18734 files and directories currently installed.)
Preparing to unpack .../tzdata_2021a-1+deb11u5_all.deb ...
Unpacking tzdata (2021a-1+deb11u5) over (2021a-1+deb11u4) ...
dpkg: error processing archive /var/cache/apt/archives/tzdata_2021a-1+deb11u5_all.deb (--unpack):
 unable to make backup link of './usr/share/zoneinfo/Etc/UTC' before installing new version: Invalid cross-device link
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/tzdata_2021a-1+deb11u5_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I’ve checked the above mentioned /var/cache/… path, but nothing there. Finally the tzdata package is not upgraded. /etc/localtime is mounted as /etc/localtime:/etc/localtime:ro from the ubuntu 22.04 host machine.

Do you have any hint where should I start?

</div>

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

You can always build the image for a specific version yourself. The image will contain the latest packages:

VERSION=11.1.0
git clone --recurse-submodules https://github.com/docker-mailserver/docker-mailserver dms-build
cd dms-build
git checkout v$VERSION
DOCKER_BUILDKIT=1 docker build -t mailserver/docker-mailserver:$VERSION .
docker tag mailserver/docker-mailserver:$VERSION mailserver/docker-mailserver:latest

Then restart your container with: docker-compose down; docker-compose up

Generally it’s bad practice to update packages inside a container. If you recreate the container, it will start again with outdated packages that you’ll have to update again. It’s better to update the image instead.

When you run DMS with default settings, you’ll get the correct localtime from the host (via bind mount). So postfix log files etc, will show the correct date/time.

Your proposed change will not enhance this. Everyone, not living in a UTC area, will see wrong date/time entries in log files and are forced to use the TZ variable.

You might want to tag it differently though, to better differentiate it as your own custom build 😅

Hello, Well, the latest :edge also failed: new tzdata package is released today… Anyway, I’ve caught the point from @polarathene and @casperklein and I did exactly what you have mentioned: deleted the /etc/localtime from the mountpoints and inserted the symlink creation command into the user-patches.sh

Great workaround for longtherm! Thank You guys!

and tell the container to update /etc/localtime to your local timezone (which should be a symlink AFAIK).

ln -sf /usr/share/zoneinfo/Zone/SubZone /etc/localtime @ user-patches.sh

I’ve tried to update the apt packages inside the docker image and the tzdata packages continously gives an error.

As discussed in this thread, you should either build images yourself with the updates, or be willing to use :edge releases that are scheduled to be updated weekly (although cache is still used if available which may delay that…)

You can write your own Dockerfile that extends our image, and updates the packages, then regularly rebuild that image. You should not be using the release tags directly and updating for a container instance, better to bake it into the images.


As for the timezone mount, if you use Podman instead of Docker, it has a --tz option, as well as a config file support to default a timezone for containers it runs.

Usually you probably won’t have any benefit from tzdata not being the latest (see changelog), unless you’re in a timezone that often experiences changes to tzdata.

As you’re already choosing to apply changes yourself, you could skip the /etc/localtime mount, and tell the container to update /etc/localtime to your local timezone (which should be a symlink AFAIK).