الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

الفصل 18الاسم في الدورة: Working with Image-based Red Hat Enterprise Linux

Build, install and update image-mode systems

In image mode, the whole operating system is a bootable container image. You build it with a Containerfile — like any container — test it, push it to a registry, and every server boots from it. Updates are one step (a new image), and a bad update is undone with one rollback. The tool on the server is bootc.

  • 7 الدروس
  • 9 الأوامر
  • 1 المعامل

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

المهارات في هذا الفصل

  • بناء أنظمة image mode وتثبيتها وتحديثها والتراجع عنها باستخدام bootc

18.1

Know image mode

Package mode changes a server package by package. Image mode replaces the whole system image in one transaction.

Package modeImage mode
BuildInstall, then change the running serverBuild an image in a Containerfile, before deployment
Updatednf update (many small changes)bootc upgrade: the new image, all or nothing
UndoHard (dnf history undo per transaction)bootc rollback: boot the old image
Same on every serverOnly with good automationYes: every server runs the same image
Good forClassic servers, many different jobsEdge devices, appliances, many identical servers

How the file system works on an image-mode system:

PathBehaviour
/usrComes from the image, read-only
/etcComes from the image; your local changes are kept and merged at updates
/varLocal data, kept across updates (logs, databases, /var/home)

تذكّر

In image mode you do not dnf install on the server. You add the package to the Containerfile and build a new image.

الأوامر في هذا الدرس

18.2

Write the Containerfile

Start FROM the RHEL bootc base image and add your packages, files and settings.

~/web-bootc/Containerfile
FROM registry.redhat.io/rhel10/rhel-bootc:10.0
 
# Software for this server role
RUN dnf -y install httpd firewalld && dnf clean all
 
# Configuration (files in /etc and /usr are part of the image)
COPY motd /etc/motd
COPY web.conf /etc/httpd/conf.d/web.conf
RUN systemctl enable httpd firewalld
 
# Web content in /usr, because /var is not updated by new images
COPY html/ /usr/share/web/html/
~/web-bootc/web.conf
DocumentRoot "/usr/share/web/html"
<Directory "/usr/share/web/html">
    Require all granted
</Directory>

انتبه

Files you put in /var in the Containerfile are copied only at the first installation. Later images do not change /var on the server. Put content that comes with the image in /usr (or /etc).

18.3

Build and test the image

Build it like any container image. You can even start it as a normal container to test the software before you make a disk from it.

podman login registry.redhat.io
cd ~/web-bootc
podman build -t quay.io/s0sta/web-bootc:1.0 .
podman images quay.io/s0sta/web-bootc
podman run --rm quay.io/s0sta/web-bootc:1.0 rpm -q httpd
httpd-2.4.63-1.el10.x86_64
podman run --rm quay.io/s0sta/web-bootc:1.0 bootc container lint
podman push quay.io/s0sta/web-bootc:1.0

bootc container lint checks the image for common mistakes before you deploy it.

18.4

Make a disk image with bootc-image-builder

bootc-image-builder turns the container image into a disk or installer image: qcow2 (KVM), raw, vmdk, ami (AWS) or anaconda-iso. It runs as a privileged container.

~/web-bootc/config.toml
[[customizations.user]]
name = "admin"
password = "ChangeMe-2026"
key = "ssh-ed25519 AAAAC3Nza...k9 admin@laptop"
groups = ["wheel"]
podman pull quay.io/s0sta/web-bootc:1.0
mkdir -p output
podman run --rm -it --privileged --pull=newer \
    --security-opt label=type:unconfined_t \
    -v ./config.toml:/config.toml:ro \
    -v ./output:/output \
    -v /var/lib/containers/storage:/var/lib/containers/storage \
    registry.redhat.io/rhel10/bootc-image-builder:latest \
    --type qcow2 \
    quay.io/s0sta/web-bootc:1.0
ls output/qcow2/
disk.qcow2
  • The builder reads the image from root's container storage, so pull (or build) it as root first.
  • config.toml adds users and SSH keys to the disk image only — not to the container image.

18.5

Install an image-mode system

Boot the disk image, or install with Anaconda and a Kickstart file that points to the image.

cp output/qcow2/disk.qcow2 /var/lib/libvirt/images/web1.qcow2
virt-install --name web1 --memory 2048 --vcpus 2 --import \
    --disk /var/lib/libvirt/images/web1.qcow2 --os-variant rhel10.0 --graphics none

With Kickstart, the ostreecontainer command replaces %packages:

ks-bootc.cfg
text
zerombr
clearpart --all --initlabel
autopart --type=lvm
network --bootproto=dhcp --activate
ostreecontainer --url quay.io/s0sta/web-bootc:1.0
rootpw --lock
user --name=admin --groups=wheel --iscrypted --password=$6$...
reboot

الأوامر في هذا الدرس

18.6

Check, update and roll back

On the server, bootc status shows the booted image and a staged or rollback image. bootc upgrade gets a newer build of the same image; bootc switch moves to another image.

sudo bootc status
sudo bootc upgrade --check
sudo bootc upgrade
sudo bootc upgrade --apply
sudo bootc switch quay.io/s0sta/web-bootc:2.0
sudo bootc rollback
systemctl list-timers bootc-fetch-apply-updates.timer
CommandWhat it does
bootc statusBooted, staged and rollback images, with versions
bootc upgrade --checkIs there a newer image? Download only the metadata
bootc upgradeDownload and stage the new image; it is used at the next reboot
bootc upgrade --applyStage it and reboot at once
bootc switch IMAGEUse another image (another tag or repository) from now on
bootc rollbackBoot the previous image at the next reboot

The update flow for a whole fleet:

  1. Change the Containerfile, build :2.0, test it.
  2. Push it (or move the tag the servers follow, for example :prod).
  3. The servers pick it up with bootc upgrade (or the automatic timer) and reboot.
  4. Problem? bootc rollback and reboot — the old system is back in minutes.

18.7

Make a quick change for testing

/usr is read-only. For a short test (a debug tool), bootc usr-overlay adds a temporary writable layer that is gone at the next reboot.

sudo bootc usr-overlay
sudo dnf install -y strace
strace -c ls
sudo systemctl reboot

في العمل

Use the overlay only for debugging. Anything that must stay goes into the Containerfile — that is the whole idea of image mode.

تدرّب

كل الأوامر في هذا الفصل