Automatic security updates on Ubuntu with unattended-upgrades
Ubuntu Server installs security updates by itself every day. How to check that yours really does, what it installs and what it doesn't, when to reboot, and how to change the time, all tested on Ubuntu 24.04.
TL;DR
- Ubuntu Server turns on automatic security updates when it is installed: unattended-upgrades installs packages from the security pocket once a day.
- Check it on your own server:
apt-config dump APT::Periodic::Unattended-Upgradeshould print"1", and theapt-daily-upgradetimer should be scheduled. - It never reboots by default, so kernel fixes wait until you reboot, unless you set
Automatic-Rebootand a time in a local file. - It updates Ubuntu's packages only: not Docker (opens in a new tab) from Docker's repository, and not your container images.
On this page
Automatic security updates on Ubuntu are already on if you installed Ubuntu Server: the unattended-upgrades package installs security updates once a day, and Ubuntu's documentation says this is enabled right after installation. By default it doesn't reboot, update software from other repositories such as Docker's, or touch your container images. So confirm it runs on your server, read its log now and then, decide how kernel updates get their reboot, and update the rest yourself.
This is the third step of our checklist for hardening an Ubuntu 24.04 server. We ran every command below on Ubuntu 24.04.5 LTS with unattended-upgrades 2.9.1 on 11 November 2026, in a container running systemd, including one real run of the daily upgrade service.
How automatic security updates work on Ubuntu 24.04
Three pieces work together:
Two systemd timers.
apt-daily.timerrefreshes the package lists, andapt-daily-upgrade.timerinstalls updates. On 24.04 the upgrade timer fires daily at 06:00 server time, plus a random delay of up to an hour, and catches up after the server was off (Persistent=true)./etc/apt/apt.conf.d/20auto-upgradessays whether those runs do anything. Ubuntu's default:APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";"1"means every day;"0"turns the step off./etc/apt/apt.conf.d/50unattended-upgradessays what may be installed. On 24.04 itsAllowed-Originsare the release (noble), its security pocket (noble-security) and the two Expanded Security Maintenance pockets (noble-apps-security,noble-infra-security), which deliver packages only on a machine attached to Ubuntu Pro. The-updatespocket, which carries ordinary bug fixes, is commented out. The release pocket is there because, as the file's comment explains, a security update can need a new dependency that is not itself a security update.
Ubuntu 24.04's release notes add that needrestart now restarts services affected by a library upgrade even in non-interactive runs such as unattended-upgrade, so running daemons don't keep using the old, vulnerable library.
1. Check that it runs on your server
Images differ: Ubuntu's minimal Docker image, for example, doesn't ship the package at all. On your server:
apt-config dump APT::Periodic::Unattended-Upgrade
systemctl list-timers 'apt-daily*'The first should print APT::Periodic::Unattended-Upgrade "1";. The second lists both timers with their next run:
NEXT LEFT LAST PASSED UNIT ACTIVATES
Wed 2026-11-11 23:14:46 UTC 7h - - apt-daily.timer apt-daily.service
Thu 2026-11-12 06:18:28 UTC 14h - - apt-daily-upgrade.timer apt-daily-upgrade.serviceIf the package is missing or the value isn't "1", install it and write the file:
sudo apt install unattended-upgrades
printf 'APT::Periodic::Update-Package-Lists "1";\nAPT::Periodic::Unattended-Upgrade "1";\n' \
| sudo tee /etc/apt/apt.conf.d/20auto-upgradesIn our test, installing the package created that file with both values set to "1". One more check: apt-config dump APT::Periodic::Enable must not print "0". Ubuntu's Docker image sets it to "0" in a file called docker-disable-periodic-update, which turns the whole daily run off; a normal server has no such file.
2. Do a dry run
This shows exactly what the next run would do, without installing anything:
sudo unattended-upgrade --dry-run --debugThe lines that matter, from our test server:
Allowed origins are: o=Ubuntu,a=noble, o=Ubuntu,a=noble-security, o=UbuntuESMApps,a=noble-apps-security, o=UbuntuESM,a=noble-infra-security
Packages that will be upgraded: apt libapt-pkg6.0t64 libpcre2-8-0 perl-base zlib1g
Option --dry-run given, *not* performing real actions
All upgrades installedAllowed origins confirms which repositories it trusts. Anything you installed from another repository won't appear in Packages that will be upgraded, however old it is.
3. Read the log
Each run writes a summary to /var/log/unattended-upgrades/unattended-upgrades.log and the installer's full output to unattended-upgrades-dpkg.log in the same folder. When we started the daily service by hand (sudo systemctl start apt-daily-upgrade.service), the summary read:
INFO Packages that will be upgraded: apt libapt-pkg6.0t64 libpcre2-8-0 perl-base zlib1g
INFO Writing dpkg log to /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
INFO All upgrades installedA quick look once a month is enough on a small server. For a nudge without logging in, see the alert ideas in our guide to monitoring a small server.
4. Decide how reboots happen
Most security updates take effect when the updated service restarts; a new kernel runs only after a reboot. When an update needs one, Ubuntu creates /var/run/reboot-required, and /var/run/reboot-required.pkgs lists the packages that asked for it.
ls /var/run/reboot-required && cat /var/run/reboot-required.pkgsYou have two choices:
- Reboot by hand, at a time you pick, after checking that file. Fine if you log in every week or two.
- Let it reboot at a quiet hour. Put your settings in a file of your own with a higher number, as Ubuntu's security documentation advises, so a package upgrade never asks you to merge them into its file. Create
/etc/apt/apt.conf.d/52unattended-upgrades-local:
// Local changes, kept apart from the packaged 50unattended-upgrades
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
Unattended-Upgrade::Remove-Unused-Dependencies "true";Files in apt.conf.d are read in name order, and for a setting like these the last one read wins, so 52 overrides 50. Confirm it with:
apt-config dump | grep -E 'Automatic-Reboot|Remove-Unused-Dependencies'In our test that printed the three values from the new file. Remove-Unused-Dependencies removes packages that nothing needs any more after each run, the equivalent of apt-get autoremove as the packaged file's comment puts it.
Warning
An automatic reboot takes your app offline for the minute or two the server needs to start. Make sure your containers come back by themselves (restart: unless-stopped in Compose) and that you have an uptime check from outside that would tell you if they didn't.
5. Move the time, if you need to
The upgrade runs around 06:00 server time. If that is your busy hour, override the timer with a drop-in rather than editing the packaged unit:
sudo systemctl edit apt-daily-upgrade.timerand write:
[Timer]
OnCalendar=
OnCalendar=*-*-* 03:00
RandomizedDelaySec=30mThe empty OnCalendar= clears the packaged time before setting yours. In our test, systemctl list-timers then showed the next run at 03:08.
What unattended-upgrades doesn't update
- Docker Engine from Docker's apt repository. Its origin isn't in
Allowed-Origins, sodocker-ceandcontainerd.iostay at the version you installed. That is usually what you want, because an upgrade restarts the Docker daemon that all your containers depend on. Update it on purpose:sudo apt update && sudo apt install --only-upgrade docker-ce docker-ce-cli containerd.io docker-compose-plugin, at a time you choose. - Your container images. The base image of your app, your database and your reverse proxy get security fixes too, but only when you pull a new image and recreate the container. Rebuild your app's image regularly so it picks up a patched base, and run
docker compose pull && docker compose up -dfor the others, with a pinned major version (postgres:18,caddy:2) so a pull never jumps a major version. - Language packages inside your app (npm (opens in a new tab), pip). Those are updated in your repository, with tools such as Dependabot.
Doing this with OpsCrew
OpsCrew, an open-source tool that deploys apps to servers you own, turns on automatic security updates on the servers it sets up, both the ones it creates at Hetzner Cloud (opens in a new tab) or DigitalOcean (opens in a new tab) and servers you already have, where the change is listed in a host plan you approve first (what OpsCrew sets up). npx opscrew secure checks the updates along with SSH, the firewall, fail2ban and Docker (deeper checks), and npx opscrew advise can read Dependabot's alerts for your repository (advise).
Next on the checklist
Next on the Ubuntu server hardening checklist: backups you can restore.
Key facts
| Fact | Value | Source |
|---|---|---|
| Default on Ubuntu Server | Security updates install automatically, once a dayUbuntu's documentation: right after installation, automatic installation of security updates is enabled, including Expanded Security Maintenance (ESM) when available. | Automatic updates, Ubuntu Server documentation (opens in a new tab)Verified on |
| Origins allowed by default on Ubuntu 24.04 | noble, noble-security, noble-apps-security (ESM Apps), noble-infra-security (ESM Infra)noble-updates, noble-proposed and noble-backports are commented out. Printed by unattended-upgrade --dry-run --debug in our test. | Automatic updates, Ubuntu Server documentation (opens in a new tab)Verified on |
| When the upgrade runs | Daily at 06:00 plus a random delay of up to 60 minutesOnCalendar and RandomizedDelaySec of apt-daily-upgrade.timer, from apt 2.8.3, the version Ubuntu 24.04 ships; the time is the server's local time. | apt 2.8.3, debian/apt-daily-upgrade.timer (opens in a new tab)Verified on |
| Automatic reboot | Off by default (Unattended-Upgrade::Automatic-Reboot "false") | Automatic updates, Ubuntu Server documentation (opens in a new tab)Verified on |
| Versions in this article's tests | Ubuntu 24.04.5 LTS, unattended-upgrades 2.9.1+nmu4ubuntu1, systemd 255Tested on 11 November 2026 in a container running systemd. | Ubuntu 24.04 LTS release notes (opens in a new tab)Verified on |
Frequently asked questions
Does unattended-upgrades reboot the server?
Not by default. When an update needs a reboot, such as a new kernel, Ubuntu creates /var/run/reboot-required and the fix takes effect only after you reboot. Set Unattended-Upgrade::Automatic-Reboot "true" and an Automatic-Reboot-Time if a reboot at a quiet hour is acceptable for your app.
Does unattended-upgrades update Docker and my containers?
No. Docker installed from Docker's own apt repository is not in the allowed origins, and container images are not apt packages at all. Update Docker Engine when you choose to, because it restarts the daemon, and pull new images and redeploy your app on a schedule.
Sources
- Automatic updates (Ubuntu Server documentation) (opens in a new tab)
- Ubuntu 24.04 LTS release notes (opens in a new tab)
- Security updates (Ubuntu security documentation) (opens in a new tab)
- apt 2.8.3, debian/apt-daily-upgrade.timer (opens in a new tab)
- Install Docker Engine on Ubuntu (opens in a new tab)
Related articles
- Deploying
Deploy a Docker app to a DigitalOcean Droplet
Create a Droplet, lock it down with a Cloud Firewall, install Docker from Docker's own repository, and run your app with Compose and automatic HTTPS. Every command tested; prices checked on 11 November 2026.
- Security
How to scan a git repository for leaked secrets
Scan a repository's full history for leaked keys with gitleaks and TruffleHog in Docker, add a pre-commit hook, know what GitHub's secret scanning covers, and clean up after a leak: rotate first, then rewrite history.
- Deploying
Cloudflare Tunnel for a self-hosted app: setup, Docker and SSH
What a Cloudflare Tunnel is, quick tunnels and named tunnels, a tested Docker Compose setup with a tunnel token, SSH through Cloudflare Access, and the limits that come with sending every request through Cloudflare.