Skip to main content
RunBook Academy

Docker & ContainersXXX Β· Host MaintenancePatching

Host patching strategy β€” what a Docker host needs and how often

Intermediate⏱ ~22 mindockerapt

What you'll learn

  • Identify which host packages affect running containers and which do not
  • Configure unattended-upgrades so it cannot restart the Docker daemon
  • Separate the security patching cadence from the Docker upgrade cadence
  • Audit what an automatic patch run would actually do before it runs

Prerequisites

Verified against Docker Engine 29.x Β· Docker Engine 28.x Β· Docker Compose 2.x Β· containerd 2.x Β· runc 1.2.x Β· BuildKit 0.20+ Β· Linux kernel 5.15+ Β· Ubuntu 24.04 LTS Β· Debian 12 (Bookworm) Β· 2026-08-11

Not yet marked complete on this device.

A Docker host runs the same operating system as everything else you patch, and for most of its packages the usual rules apply: apply security updates promptly, automatically where you can.

Two things make it different. The docker-ce and containerd.io packages restart services that every workload on the machine depends on, and the container isolation model means several host libraries reach inside containers in ways that are not obvious from the package list.

What reaches into a container

Containers share the host kernel and, for some subsystems, the host’s policy configuration. A patch to any of these changes behaviour inside every container on the machine:

Host componentHow it reaches containersNeeds
KernelShared by every container; namespaces, cgroups, overlayfs, seccomp are kernel featuresReboot
libseccomp2The daemon uses it to compile the seccomp profile applied at container startDaemon restart, then container recreation
AppArmor / SELinux policyApplied to container processes at startContainer recreation
containerd.io (containerd, runc)runc builds the container; the shim supervises itContainer recreation for the fix to be real
docker-ceThe daemonDaemon restart
systemdOwns the cgroup hierarchy the daemon delegates fromUsually nothing; occasionally a reboot
glibc, OpenSSL, zlibNothing β€” containers carry their ownNothing on the host side

That last row is the one that surprises people, and it cuts both ways. A glibc CVE on the host does not affect containers, because each image ships its own libc. But it also means patching the host does not patch your containers: a glibc CVE inside myapp:release-2026-08 is fixed by rebuilding the image, and no amount of host patching will touch it.

The unattended-upgrades problem

Ubuntu and Debian ship unattended-upgrades and it is a good default. On a Docker host, the default configuration has a specific hazard.

Read-only / Safeallowed origins
$ grep -A 8 'Allowed-Origins' /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Allowed-Origins {
      "${distro_id}:${distro_codename}";
      "${distro_id}:${distro_codename}-security";
      "${distro_id}ESMApps:${distro_codename}-apps-security";
      "${distro_id}ESM:${distro_codename}-infra-security";
};

Illustrative output

Read that carefully, because it is better news than the folklore suggests. The default allows only origins whose distro_id matches the distribution. Docker’s repository publishes with a different origin:

Read-only / Safedocker repo origin
$ grep -hE '^(Origin|Label|Suite)' /var/lib/apt/lists/download.docker.com*InRelease
Label: Docker CE
Origin: Docker
Suite: noble

Illustrative output

So a stock unattended-upgrades does not upgrade Docker. Origin: Docker is not in the allowed list.

Read-only / Safeaudit the automatic path
# Is unattended-upgrades even enabled?
systemctl is-enabled unattended-upgrades.service apt-daily-upgrade.timer

# What does it consider in scope? (does not install anything)
sudo unattended-upgrade --dry-run --debug 2>&1 | head -40

# Anything else scheduled that touches apt?
sudo grep -rn 'apt-get\|apt ' /etc/cron.d/ /etc/cron.daily/ 2>/dev/null

# What is currently upgradable, and from which origin
apt list --upgradable 2>/dev/null

Making it explicit

Do not rely on the default staying the default. State the exclusion.

Configuration change/etc/apt/apt.conf.d/52docker-unattended
// Docker Engine and containerd restart their services from the package
// postinstall. On this host that stops every container unless live-restore
// is enabled, so both are upgraded only in a maintenance window.
Unattended-Upgrade::Package-Blacklist {
  "docker-ce$";
  "docker-ce-cli$";
  "containerd.io$";
};

Two details matter. The $ anchors the pattern β€” these are Python regular expressions matched against package names, and without the anchor docker-ce also matches docker-ce-rootless-extras. And putting this in your own file rather than editing 50unattended-upgrades means a package upgrade of unattended-upgrades cannot silently revert it.

The belt-and-braces version is an apt pin, which stops manual mistakes too:

Configuration change/etc/apt/preferences.d/docker-hold
Package: docker-ce docker-ce-cli containerd.io
Pin: origin download.docker.com
Pin-Priority: 100

Priority 100 means β€œinstalled, but do not upgrade automatically”. An explicit apt-get install docker-ce=<version> still works, which is exactly the behaviour you want: automatic runs skip it, maintenance windows do not.

Cadences

StreamCadenceMechanism
Distribution security updates (excluding Docker, excluding kernel)Automatic, dailyunattended-upgrades
KernelMonthly, or immediately for a rated CVEManual, with a reboot window
Docker packagesMonthly patch, quarterly featureMaintenance window, the runbook from the upgrades part
Container imagesWeekly rebuild, or on base image updateBuild pipeline

The kernel is separate from the automatic stream for one reason: installing a kernel is harmless and applying it requires a reboot. Automating the install without automating the reboot produces hosts that report as patched and are running the old kernel β€” the subject of the next lesson.

Knowledge check

Knowledge check Β· 4 questions

  1. Q1. A critical glibc CVE is announced. You patch glibc on the Docker host. What is the effect on your containers?

  2. Q2. Why does a stock unattended-upgrades configuration not upgrade Docker Engine?

  3. Q3. Which host components change behaviour inside running or future containers when patched? Select all that apply.

  4. Q4. After upgrading containerd.io to fix a runc CVE, every already-running container must be recreated before the fix applies to it.

Passing score: 75%. Answers are checked in this browser.