Skip to content

Docker & Podman: Patching & updates

Docker & Podman commands for patching & updates (tags: #patching).

Index
4 items

Docker: Check the base OS of an image

Safe

Tells you which package manager to patch with in the Dockerfile (apt, apk, dnf, microdnf).

docker run --rm --entrypoint cat <image>:<tag> /etc/os-release
What each part does
  1. docker run --rmthrowaway container
  2. --entrypoint catskip the image entrypoint and just run cat
  3. /etc/os-releasedistro name and version

Also known as: image os · base image distro · which distro image

Docker: Patch OS packages in a Debian or Ubuntu Dockerfile

Safe

Dockerfile line: pulls in all security fixes for the base image at build time. Put it right after FROM.

RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*
What each part does
  1. apt-get updaterefresh package lists
  2. apt-get upgrade -yupgrade every installed package
  3. rm -rf /var/lib/apt/lists/*keep the image small

My note Only build fixes when the build is not cached: docker build --pull --no-cache

  • #docker
  • #patching
  • #build
  • #vulnerabilities

Also known as: dockerfile apt upgrade · patch container image · fix image cve

Docker: Patch OS packages in an Alpine Dockerfile

Safe

Dockerfile line: upgrade every Alpine package to the latest fixed version at build time.

RUN apk upgrade --no-cache
What each part does
  1. apk upgradeupgrade all installed packages
  2. --no-cachedo not keep the package index in the image
  • #docker
  • #patching
  • #build
  • #vulnerabilities

Also known as: dockerfile apk upgrade · alpine cve · patch alpine image

Docker: Rebuild an image with the latest base image

Safe

Most image CVEs are fixed by rebuilding: a fresh base image plus re-run package installs.

docker build --pull --no-cache -t <image>:<tag> .
What each part does
  1. --pullalways download the newest version of the FROM image
  2. --no-cachere-run every step so apt/apk get today's fixes
  3. -t <image>:<tag>name the result

My note Scan before pushing: trivy image --severity HIGH,CRITICAL --ignore-unfixed <image>:<tag>

  • #docker
  • #patching
  • #build
  • #vulnerabilities

Also known as: rebuild image · refresh base image · fix image vulnerabilities

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…