ref-manual/classes.rst: document the image-container class
PATCH v3 1/1 ref-manual/classes.rst: document the image-container class
Add documentation for the image-container class, which is a simple class to generate an image suitable for creating a container.
This answers in part to questions asked in [YOCTO #14368].
It also adds documentation for IMAGE_CONTAINER_NO_DUMMY, which was added in OE-Core with commit f0645e172bb8 ("image-container.bbclass: Error if not using linux-dummy").
---
Changes in v3:
- Apply suggestions from Quentin (thanks!)
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Review from Quentin (thanks!)
- Merge patch 1 and 2.
- Rephrase class and variable to highlight that IMAGE_FSTYPES should
contain container, and that the class should not be inherited
directly.
- Link to v1: https://patch.msgid.link/[email protected]
--- documentation/ref-manual/classes.rst | 46 ++++++++++++++++++++++++++++++++++ documentation/ref-manual/variables.rst | 18 +++++++++++++ 2 files changed, 64 insertions(+)
documentation/ref-manual/classes.rst +46 -0
@@ -1258,6 +1258,52 @@ The :ref:`ref-classes-image_types` class also handles conversion and compression :term:`IMAGE_FSTYPES`. This would also be similar for Virtual Box Virtual Disk Image ("vdi") and QEMU Copy On Write Version 2 ("qcow2") images. +.. _ref-classes-image-container: + +``image-container`` +=================== + +The :ref:`ref-classes-image-container` class is automatically inherited in +:doc:`image </ref-manual/images>` recipes that have the ``container`` image type +in :term:`IMAGE_FSTYPES`. It provides relevant settings to generate an image +ready for use with an :wikipedia:`OCI <Open_Container_Initiative>`-compliant +container management tool, such as :wikipedia:`Podman <Podman>` or +:wikipedia:`Docker <Docker_(software)>`. + +.. note:: + + This class neither builds nor installs container management tools on the + target. Those tools are available in the :yocto_git:`meta-virtualization + </meta-virtualization>` layer. + +You should set the :term:`PREFERRED_PROVIDER` for the Linux kernel to +``linux-dummy`` in a :term:`configuration file`:: + + PREFERRED_PROVIDER_virtual/kernel = "linux-dummy" + +Otherwise an error is triggered. If desired, the +:term:`IMAGE_CONTAINER_NO_DUMMY` variable can be set to "1" to skip this check. + +The ``linux-dummy`` recipes acts as a Linux kernel recipe but builds nothing. It +is relevant to use as the preferred Linux kernel provider in this case as a +container image does not need to include a Linux kernel. Selecting it as the +preferred provider for the kernel will also decrease build time. + +Using this class only deploys an additional ``tar.bz2`` archive to +:term:`DEPLOY_DIR_IMAGE`. This archive can be used in a container file (a file +typically named ``Dockerfile`` or ``Containerfile``). For example, to be used with +:wikipedia:`Podman <Podman>` or :wikipedia:`Docker <Docker_(software)>`, the +`container file <https://docs.docker.com/reference/dockerfile/>`__ could contain +the following instructions: + +.. code-block:: dockerfile + + FROM scratch + ADD ./image-container-qemux86-64.rootfs.tar.bz2 / + ENTRYPOINT /bin/sh + +This is suitable to build a container using our generated root filesystem image. + .. _ref-classes-image-live: ``image-live``
documentation/ref-manual/variables.rst +18 -0
@@ -3955,6 +3955,24 @@ system and gives an overview of their function and contents. variable, see the :ref:`ref-classes-image_types` class file, which is ``meta/classes-recipe/image_types.bbclass``. + :term:`IMAGE_CONTAINER_NO_DUMMY` + When an image recipe has the ``container`` image type in + :term:`IMAGE_FSTYPES`, it expects the :term:`PREFERRED_PROVIDER` for + the Linux kernel (``virtual/kernel``) to be set to ``linux-dummy`` from a + :term:`configuration file`. Otherwise, an error is triggered. + + When set to "1", The :term:`IMAGE_CONTAINER_NO_DUMMY` variable allows the + :term:`PREFERRED_PROVIDER` variable to be set to another value, thus + skipping the check and not triggering the build error. Any other value + will keep the check. + + This variable should be set from the image recipe using the ``container`` + image type. + + See the documentation of the :ref:`ref-classes-image-container` class for + more information on why setting the :term:`PREFERRED_PROVIDER` to + ``linux-dummy`` is advised with this class. + :term:`IMAGE_DEVICE_TABLES` Specifies one or more files that contain custom device tables that are passed to the ``makedevs`` command as part of creating an image.
---
base-commit: d84d916d4fc505e8386693306b6a90b0064c0518
change-id: 20251023-image-container-fdc6d79f6729
Hi Antonin,
Minor typos and one comments below, feel free to fix while applying.
Thanks!
Quoted 32 lines · Antonin Godard via lists.yoctoproject.org
Add documentation for the image-container class, which is a simple class to generate an image suitable for creating a container.
This answers in part to questions asked in [YOCTO #14368].
It also adds documentation for
IMAGE_CONTAINER_NO_DUMMY, which was added in OE-Core with commitf0645e172bb8("image-container.bbclass: Error if not using linux-dummy").Signed-off-by Antonin Godard <[email protected]>---
Changes in v3:
- Apply suggestions from Quentin (thanks!)
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- Review from Quentin (thanks!)
- Merge patch 1 and 2.
- Rephrase class and variable to highlight thatIMAGE_FSTYPESshould contain container, and that the class should not be inherited
directly.
- Link to v1: https://patch.msgid.link/[email protected]--- documentation/ref-manual/classes.rst | 46 ++++++++++++++++++++++++++++++++++ documentation/ref-manual/variables.rst | 18 +++++++++++++ 2 files changed, 64 insertions(+)documentation/ref-manual/classes.rst +0
-0
documentation/ref-manual/classes.rst The :ref:`ref-classes-image_types` class also handles conversion and compression · line 1260
Quoted 3 lines
documentation/ref-manual/classes.rst +0
-0@@ -1258,6 +1258,52 @@ The :ref:`ref-classes-image_types` class also handles conversion and compression :term:`IMAGE_FSTYPES`. This would also be similar for Virtual Box Virtual Disk Image ("vdi") and QEMU Copy On Write Version 2 ("qcow2") images.
Unrelated to this patch, I'm wondering if image_types is at the right location in order for the classes to be alphabetically sorted.
It is currently between image-buildinfo and image-live.
Quoted 16 lines
documentation/ref-manual/classes.rst +16
-0+.. _ref-classes-image-container: + +``image-container`` +=================== + +The :ref:`ref-classes-image-container` class is automatically inherited in +:doc:`image </ref-manual/images>` recipes that have the ``container`` image type +in :term:`IMAGE_FSTYPES`. It provides relevant settings to generate an image +ready for use with an :wikipedia:`OCI <Open_Container_Initiative>`-compliant +container management tool, such as :wikipedia:`Podman <Podman>` or +:wikipedia:`Docker <Docker_(software)>`. + +.. note:: + + This class neither builds nor installs container management tools on the + target. Those tools are available in the :yocto_git:`meta-virtualization
documentation/ref-manual/classes.rst The :ref:`ref-classes-image_types` class also handles conversion and compression · line 1286
Quoted 10 lines
documentation/ref-manual/classes.rst +10
-0+ </meta-virtualization>` layer. + +You should set the :term:`PREFERRED_PROVIDER` for the Linux kernel to +``linux-dummy`` in a :term:`configuration file`:: + + PREFERRED_PROVIDER_virtual/kernel = "linux-dummy" + +Otherwise an error is triggered. If desired, the +:term:`IMAGE_CONTAINER_NO_DUMMY` variable can be set to "1" to skip this check. +
Here it's the first time we say "check", before we say an error is triggered. This refers to the check that triggers to the error but it may not be clear for the user reading this for the first time. I guess we could say "to avoid triggering an error"?
documentation/ref-manual/classes.rst The :ref:`ref-classes-image_types` class also handles conversion and compression · line 1287
Quoted 1 line
documentation/ref-manual/classes.rst +1
-0+The ``linux-dummy`` recipes acts as a Linux kernel recipe but builds nothing. It
s/recipes/recipe/
Quoted 27 lines
documentation/ref-manual/classes.rst +19
-0+is relevant to use as the preferred Linux kernel provider in this case as a +container image does not need to include a Linux kernel. Selecting it as the +preferred provider for the kernel will also decrease build time. + +Using this class only deploys an additional ``tar.bz2`` archive to +:term:`DEPLOY_DIR_IMAGE`. This archive can be used in a container file (a file +typically named ``Dockerfile`` or ``Containerfile``). For example, to be used with +:wikipedia:`Podman <Podman>` or :wikipedia:`Docker <Docker_(software)>`, the +`container file <https://docs.docker.com/reference/dockerfile/>`__ could contain +the following instructions: + +.. code-block:: dockerfile + + FROM scratch + ADD ./image-container-qemux86-64.rootfs.tar.bz2 / + ENTRYPOINT /bin/sh + +This is suitable to build a container using our generated root filesystem image. + .. _ref-classes-image-live: ``image-live``documentation/ref-manual/variables.rst +0
-0
documentation/ref-manual/variables.rst system and gives an overview of their function and contents. · line 3964
Quoted 10 lines
documentation/ref-manual/variables.rst +7
-0@@ -3955,6 +3955,24 @@ system and gives an overview of their function and contents. variable, see the :ref:`ref-classes-image_types` class file, which is ``meta/classes-recipe/image_types.bbclass``. + :term:`IMAGE_CONTAINER_NO_DUMMY` + When an image recipe has the ``container`` image type in + :term:`IMAGE_FSTYPES`, it expects the :term:`PREFERRED_PROVIDER` for + the Linux kernel (``virtual/kernel``) to be set to ``linux-dummy`` from a + :term:`configuration file`. Otherwise, an error is triggered. + + When set to "1", The :term:`IMAGE_CONTAINER_NO_DUMMY` variable allows the
s/The/the/
Antonin Godard
AppliedQuoted 10 lines · Antonin Godard
Add documentation for the image-container class, which is a simple class to generate an image suitable for creating a container.
This answers in part to questions asked in [YOCTO #14368].
It also adds documentation for
IMAGE_CONTAINER_NO_DUMMY, which was added in OE-Core with commitf0645e172bb8("image-container.bbclass: Error if not using linux-dummy").[...]
Applied, thanks!
[1/1] ref-manual/classes.rst: document the image-container class
commit: 6ce00e5875eb3469fefd55cc22acaaeaf620053a
Best regards,