Cron in Docker runs in UTC: setting the container timezone with TZ and tzdata
TZ in a cron container did nothing on Ubuntu and Alpine images, which lack tzdata. On Debian the schedule moved while its jobs kept UTC. A fix that works on both.
9 min read
Your compose file says TZ: Europe/Bratislava. The crontab says 0 9 * * *. The report shows up at
10:00, because the container is still on UTC, and in summer it’ll show up at 11:00. Or the
schedule is right and the job’s log says it ran an hour before it did.
We started cron containers on three base images with TZ set and watched which hour they fired
at, and what time the job itself thought it was. None of the three got both right out of the
box.
podman 5.7 · debian 13 · ubuntu 26.04 · alpine 3.23 · TZ=Europe/Bratislava
- ubuntu + TZno tzdata in the image, cron stayed on UTC
- alpine + TZsame, busybox crond stayed on UTC
- debian + TZran at the local hour, but date said UTC
- zone typono error, everything quietly on UTC
- CRON_TZ lineignored by debian cron and busybox
- link localtimeschedule and job both on CET, all 3 images
- runwisptwo zones in one container, typo refused
Short answer
Cron in a container schedules jobs in whatever zone the C library resolves for the cron process.
Setting TZ only works if the image has the time zone database, and ubuntu and alpine images
don’t, so they fall back to UTC without a word. Debian’s image does, but Debian’s cron doesn’t pass
TZ on to its jobs, so the schedule follows TZ while date inside the job says UTC. The fix
that worked on all three: install tzdata and link /etc/localtime to the zone in a small
entrypoint, so -e TZ= sets the time for cron and every job alike (the
script is below). If you’d rather not touch the image,
RunWisp, an open-source cron replacement that ships as a single binary, has the zone database
built in and takes a timezone per task, as tested below.
How we tested
Each container got a crontab with two lines, both due two minutes later: one written with the UTC hour, one with the Bratislava hour (UTC+1 in December). Whichever line fires tells you the zone cron schedules in. Both lines ran the same script:
#!/bin/sh
echo "$1 ran, date says $(date +%H:%M_%Z), TZ=${TZ:-unset}" >> /tmp/log
The images were debian:13 with cron 3.0pl1-197, ubuntu:26.04 with cron 3.0pl1-200ubuntu1, and
alpine:3.23 with its built-in BusyBox 1.37 crond, plus Supercronic 0.2.52 on Alpine. All ran
under Podman 5.7, which behaves like Docker here: -e TZ is just an environment variable, and the
image decides what it means.
TZ without tzdata does nothing
Every container here ran with -e TZ=Europe/Bratislava. The jobs were due at 11:37 Bratislava
time, which is 10:37 UTC:
| Image, scheduler | tzdata | Line that fired | Job’s date says |
|---|---|---|---|
| debian:13, cron | ✓ | Bratislava | 10:37 UTC |
| ubuntu:26.04, cron | ✗ | UTC | 10:37 UTC |
| ubuntu:26.04 + tzdata, cron | ✓ | Bratislava | 10:37 UTC |
| alpine:3.23, crond | ✗ | UTC | 10:37 UTC |
| alpine:3.23 + tzdata, crond | ✓ | Bratislava | 11:37 CET |
| alpine:3.23, Supercronic | ✗ | UTC | 10:37 UTC |
| alpine + tzdata, Supercronic | ✓ | Bratislava | 11:37 CET |
TZ=Europe/Bratislava tells the C library to load /usr/share/zoneinfo/Europe/Bratislava. The
Ubuntu and Alpine images don’t have that directory, and installing cron on Ubuntu doesn’t bring
it in. When the file isn’t there, glibc and musl both carry on in UTC without a warning in
docker logs. Only the zone abbreviation in date gives it away:
$ docker run --rm -e TZ=Europe/Bratislava ubuntu:26.04 date
Thu Dec 3 10:42:26 UTC 2026
Supercronic is a Go program and goes through the same thing: no zoneinfo, no error, UTC. Its
README does say you may need tzdata.
On Debian the schedule moves and the job’s clock doesn’t
The debian:13 image ships tzdata, so -e TZ works for the cron daemon. The Bratislava line
fired at 11:37 local time. The job then printed this:
LOCAL-line ran, date says 10:37_UTC, TZ=unset
Debian’s cron, which Ubuntu also ships, starts every job with a fresh environment: HOME,
LOGNAME, PATH, SHELL, and whatever the crontab sets. TZ from docker run -e isn’t on that
list, so the job falls back to /etc/localtime, and in the Debian image that’s a link to
Etc/UTC. Ubuntu with tzdata installed behaves the same way. (The missing environment is the
same problem that hides your other variables, covered in
cron in a Docker container: missing env vars.)
It sounds harmless until a job uses the date. A backup at 30 0 * * * that writes
db-$(date +%F).sql.gz runs at 00:30 Bratislava time, when it’s still 23:30 in UTC. Every
backup gets yesterday’s date, and on the 1st of the month it lands in last month’s folder.
Alpine’s BusyBox crond keeps its environment, so with tzdata installed its jobs got TZ and
printed CET.
A typo looks exactly like UTC
TZ=Europe/Bratislav, one letter short, gave the same result on every image: the UTC line fired,
and nothing complained. On Debian, date even makes up a zone name out of the part before the
slash:
$ docker run --rm -e TZ=Europe/Bratislav debian:13 date
Thu Dec 3 10:42:26 Europe 2026
If a job runs an hour or two off, docker exec <container> date is the first
thing to run. Check that the abbreviation is a real one (CET, EST), not UTC and not a word
from your TZ value.
CRON_TZ in a container
Debian’s cron and BusyBox crond both ignored a CRON_TZ=Europe/Bratislava line and ran the UTC
line. Supercronic honored it, but only with tzdata installed. Without it, Supercronic refused to
start, which is the most helpful failure in this whole post:
level=fatal msg="unknown time zone Europe/Bratislava"
Even when CRON_TZ works, it only moves the schedule. Supercronic’s job still printed UTC. The
cron implementations comparison has the full CRON_TZ and TZ=
matrix across six distros.
The fix: link /etc/localtime at startup
/etc/localtime is the file every program reads when TZ isn’t set, cron’s jobs included. Point
it at the zone and the daemon and its jobs agree. This entrypoint does that from $TZ and refuses
to start if the zone doesn’t exist:
#!/bin/sh
# tz-entrypoint.sh
set -e
if [ -n "$TZ" ]; then
if [ ! -f "/usr/share/zoneinfo/$TZ" ]; then
echo "TZ=$TZ: no such zone in /usr/share/zoneinfo (is tzdata installed?)" >&2
exit 1
fi
ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime
fi
exec "$@"
For Debian or Ubuntu:
FROM ubuntu:26.04
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cron tzdata \
&& rm -rf /var/lib/apt/lists/*
COPY --chmod=755 tz-entrypoint.sh /usr/local/bin/
COPY --chmod=644 crontab /etc/cron.d/app
ENTRYPOINT ["tz-entrypoint.sh"]
CMD ["cron", "-f"]
Lines in /etc/cron.d take a user column: 30 0 * * * root /app/backup.sh. Keep the
--chmod=644, too. Our first run bind-mounted a group-writable crontab into /etc/cron.d, and
Debian’s cron skipped it without saying anything, which cost us a test round.
For Alpine:
FROM alpine:3.23
RUN apk add --no-cache tzdata
COPY --chmod=755 tz-entrypoint.sh /usr/local/bin/
COPY --chmod=644 crontab /etc/crontabs/root
ENTRYPOINT ["tz-entrypoint.sh"]
CMD ["crond", "-f"]
Then pick the zone where you run it:
services:
app:
build: .
init: true
environment:
TZ: Europe/Bratislava
With this, all three images fired the Bratislava line, and the job printed 11:44_CET. A typo in
TZ, or an image without tzdata, now exits with the message above instead of running on UTC.
init: true is there because cron -f as PID 1 ignores docker stop; the
env vars post explains that part.
The entrypoint has to run as root to replace /etc/localtime, which the cron daemon needs anyway.
For an image that runs as a non-root user, do the ln -sf in a RUN line at build time and fix
the zone in the image.
The other common answer is a bind mount of the host’s file:
volumes:
- /etc/localtime:/etc/localtime:ro
It worked in our test without tzdata in the image, since /etc/localtime is the zone data
itself. It ties the container to the host’s zone, which is fine on a home server you set up
yourself and less fine in an image someone else will run. Podman users can skip both with
podman run --tz=Europe/Bratislava, which worked even on the bare Ubuntu image.
Or keep the container in UTC
For most jobs, UTC is the better choice. It has no daylight saving time, so no hour is skipped or repeated. A job at 02:30 local time sits in exactly the hour the clocks skip in March and, in Europe, repeat in October, and what happens to it then depends on the scheduler, as the daylight saving time post shows. Logs from different containers also line up without converting.
The price is that you convert schedules by hand, and the conversion changes twice a year. A report
due at 09:00 Bratislava time is 0 8 * * * in winter and 0 7 * * * in summer. If a job has to
follow the local clock, give the container the local zone with the fix above. If it doesn’t, leave
it on UTC and write the hour in UTC.
Time zones in RunWisp
RunWisp is an open-source cron replacement that ships as a single binary. It reads the zone from its config, and the time zone database is compiled into the binary, so the schedule doesn’t depend on what the image has installed. Each task can also have its own zone:
[daemon]
timezone = "Europe/Bratislava"
[tasks.nightly-backup]
cron = "30 0 * * *"
run = "/app/backup.sh"
[tasks.tokyo-report]
cron = "0 9 * * 1-5"
timezone = "Asia/Tokyo"
run = "/app/report.sh"
We ran RunWisp 1.11.0 through the same test with three tasks: one on the UTC hour, one on the
Bratislava hour, and one on the Tokyo hour with timezone = "Asia/Tokyo". The Bratislava and Tokyo
tasks fired at the same minute, each on its own zone’s clock. The task written with the UTC hour
didn’t fire, because RunWisp read it in Bratislava time. That’s two zones in one container, which none of the crons above can
do. Debian’s cron doesn’t support per-line zones at all, and Supercronic takes one CRON_TZ per
crontab.
We also copied the binary into the bare ubuntu:26.04 image, which has no tzdata. With
[daemon] timezone set, both tasks still fired on the right hour.
The typo from earlier doesn’t get through. The daemon refuses to start:
$ docker compose logs runwisp
ERROR invalid daemon.timezone: "Europe/Bratislav" is not a valid IANA timezone (e.g. "UTC", "America/New_York"): unknown time zone Europe/Bratislav
runwisp validate prints the same error, so it can run in CI before the config reaches a server.
To see which zone a running daemon uses, and when each task runs next:
$ docker compose exec runwisp runwisp status --json
"resolvedTimezone": "Europe/Bratislava",
"timezoneSource": "config",
...
"name": "nightly-backup",
"cron": "30 0 * * *",
"nextRunAt": "2026-12-04T00:30:00+01:00",
...
"name": "tokyo-report",
"cron": "0 9 * * 1-5",
"nextRunAt": "2026-12-04T01:00:00+01:00",
09:00 in Tokyo is 01:00 in Bratislava, and that’s what it says. The web UI shows the daemon’s zone in its sidebar, next to each task’s next run.
The official image also installs tzdata for the commands your tasks run, so a TZ variable sets
their clocks too. In our test, with TZ set next to [daemon] timezone, the tasks’ date
printed CET:
services:
runwisp:
image: runwisp/runwisp:1.11.0
restart: unless-stopped
ports:
- "9477:9477"
environment:
RUNWISP_PASSWORD: change-me
TZ: Europe/Bratislava
volumes:
- ./runwisp:/etc/runwisp
- runwisp-data:/var/lib/runwisp
volumes:
runwisp-data:
Put the TOML above in ./runwisp/runwisp.toml, run docker compose up -d, and open
http://localhost:9477. Each run keeps its start time and output, so when someone asks
whether the backup ran at 00:30 or 01:30, the run history answers it. The
Docker guide covers running tasks inside your
app’s own containers, and Docker Compose cron jobs with a web UI
compares it with the other ways to schedule jobs in a compose stack.
Common questions
How do I set the timezone for cron in a Docker container?
Why is TZ ignored in my Docker container?
Why does my cron job print UTC when cron runs in local time?
Does CRON_TZ work in a Docker container?
Should a Docker container run in UTC?
How do I run cron jobs in different time zones in one Docker container?
Read next
-
Watchtower is archived: auto-update Docker Compose containers with a cron job instead
containrrr/watchtower was archived in December 2025, and 1.7.1 panics on Docker 29. A tested cron script that pulls and restarts your compose stacks, and the traps it avoids.
-
ZFS scrub schedule on Ubuntu and Proxmox: the monthly cron job skips degraded pools
Debian-based distros, Proxmox VE included, scrub ZFS pools from /etc/cron.d on the second Sunday. We broke a mirror in a VM to see what that job reports, and how to get an alert when a scrub finds errors.