Build a Container Image¶
KIWI NG is capable of building native Container Images from scratch and derived ones. KIWI NG Container images are considered to be native since the KIWI NG tarball image is ready to be loaded into a Container Runtime like Podman, Docker or Containerd, including common container configurations.
The Container configuration metadata is provided to KIWI NG as part of the
XML description file using the
<containerconfig> tag. The following configuration metadata can be
name: Specifies the repository name of the Container Image.
tag: Sets the tag of the Container Image.
maintainer: Specifies the author field of the container, this is equivalent to the
MAINTAINERdirective in a
user: Sets the user name or user id (UID) to be used when running
subcommand. Equivalent of the
USERdirective of a
workingdir: Sets the working directory to be used when running
entrypoint. Equivalent of the
WORKDIRdirective in a
containerconfig child tags:
subcommand: Provides the default execution parameters of the container. Equivalent of the
CMDdirective in a
labels: Adds custom metadata to an image using key-value pairs. Equivalent to one or more
LABELdirectives in a
expose: Define which ports can be exposed to the outside when running this container image. Equivalent to one or more
EXPOSEdirectives in a
environment: Sets environment variables using key-value pairs. Equivalent to one or multiple
ENVdirectives in a
entrypoint: Sets the binary via which all commands inside the container will be executed. Equivalent of the
ENTRYPOINTdirective in a
volumes: Create mountpoints with the given name and mark them to hold external volumes from the host or from other containers. Equivalent to one or more
VOLUMEdirectives in a
The following example illustrates how to build a Container Image based on openSUSE Leap:
Make sure you have checked out the example image descriptions, see Example Appliance Descriptions.
Virtualization/containersrepository to your list:
$ zypper addrepo http://download.opensuse.org/repositories/Virtualization:/containers/<DIST> container-tools
where the placeholder
<DIST>is the preferred distribution.
Install umoci and skopeo tools
$ zypper in umoci skopeo
Build the image with KIWI NG:
$ sudo kiwi-ng system build \ --description kiwi/build-tests/x86/leap/test-image-docker \ --set-repo obs://openSUSE:Leap:15.3/standard \ --target-dir /tmp/myimage
Test the Container image.
First load the new image into your Container Runtime:
$ podman load -i kiwi-test-image-docker.x86_64-1.15.3.docker.tar.xz
and then run the image:
$ podman run --rm -it buildsystem /bin/bash