Building a container image for your software
Building a container image for your software¶
A container image is a lightweight, standalone software package that includes the code, tools, libraries, and settings required to run a piece of
software. The configuration for a container image is stored in a file called a Containerfile.
Prerequisites
- Podman
- An RPM package (
auto-apps) in an RPM package repository (/var/tmp/my_repo)
Procedure
-
Create a
Containerfilethat includes the RPM package that you created in Packaging applications with RPM:```text FROM quay.io/fedora/fedora:40
COPY my_repo /tmp/my_repo
RUN ls -l /tmp && ls -l /tmp/my_repo
RUN dnf install -y /tmp/my_repo/x86_64/auto-apps-0.1*.rpm && dnf clean all ```
-
Copy the RPM repository from
/var/tmp/my_repoto the same directory where you have created theContainerfilefile:console $ cp -r /var/tmp/my_repo . -
Run
podman buildin the same directory as yourContainerfileto build the container image, and name the container imageauto-apps:console $ sudo podman build -t localhost/auto-apps:latest -f Containerfile -
Start a container from your
auto-appscontainer image,console $ sudo podman run -it auto-apps -
From within the running container, verify that your RPM package is present.
console $ rpm -q auto-appsIf the
auto-appsRPM was embedded successfully in the container, the output of therpm -qcommand displays the version of your package:console $ auto-apps-0.1-1.fc40.x86_64
Now that you have a functional auto-apps container image, you can embed your
containerized applications in the OS image with OSBuild.
Next steps
After creating a container image for your application, you can embed it in an OS image.
Depending on your needs, you can use one of two methods to embed the container image in your operating system image:
- Recommended method: Create the container image and add it to a remote container registry.Then, pull the container image from the remote registry to include in the OS image. This method is the only reliable, reproducible method for OS image builds and is therefore recommended.
- Development method: Create the container image and add it to a local RPM repository. Then, pull the container image from your local repository to include in the OS image. Only use this method to build OS images for development and experimentation purposes.