How to create RHEL 7/8/9 repositories in a single RHEL 9 environment using Podman?

 

 

How to create RHEL 7/8/9 repositories in a single RHEL 9 environment using Podman? 

 

Environment

  • Red Hat Enterprise Linux Server release 7/8/9
  • Podman

Issue

  • Normally, it is not possible to create multiple RHEL repository servers for versions 7, 8, and 9 on a single RHEL server.

Resolution

  • There are various methods to configure RHEL repositories for multiple releases, such as 7 and 8, on a single RHEL 9 server using Podman.

  • Please find below sample plans for this request. Feel free to modify them as per your requirements.

    • RHEL 7 Repository: The RHEL 7 repository should be utilized with a UBI7 container.
    • RHEL 8 Repository: The RHEL 8 repository should be utilized with a UBI8 container.
    • RHEL 9 Repository: The RHEL 9 repository should be utilized with a UBI9 container.

Example:

  • Create a containe file
    $ cat ubi7containerfile
    FROM ubi7/ubi:latest
    RUN yum install -y yum-utils createrepo wget bind-utils httpd && \
    yum clean all
    RUN echo "It works" > /var/www/html/index.html
    EXPOSE 80
    CMD ["httpd", "-D", "FOREGROUND"]
    $
  • Build the Image Using the Container File
    $ podman build -f ubi7containerfile -t ubi7repos 
  • Start the container with local volumesStart the Container with Local Volumes:
    $ podman run -d --name ubi7repos -v /data/repos/rhel7:/var/www/html:Z -p 8081:80 ubi7repos
  • Verify the Container is Running Successfully:
    $ podman ps
  • Login Inside the Container:
    $ podman exec -it ubi7repos /bin/bash
  • Start the Repo Sync Based on Your Required Repositories
    # reposync --gpgcheck -l --repoid=rhel-7-server-rpms --download_path=/var/www/html --downloadcomps --download-metadata
  • Add Port 8080 to the Firewalld Configuration
    # firewall-cmd --permanent --add-port=8080/tcp
    # firewall-cmd --reload

Continue the same setups to set up RHEL repositories for different releases using their respective UBI images and repository IDs on a single RHEL 9 server with Podman, start by pulling the appropriate UBI images for each RHEL release. Then, run containers using these images and configure the RHEL repositories within each container by registering and enabling the necessary repositories.

 

Diagnostic Steps

To check and debug Podman logs, you can use a combination of Podman commands and Linux tools.

  • Podman provides a logs command to view the logs of a specific container. Replace with the name or ID of your container.
    $ podman logs <container_name_or_id>
  • Use the --log-level=debug option to get more detailed logs during the build process.
    $ podman build --log-level=debug -t ubi7repos -f ubi7containerfile

 

Comments

Popular posts from this blog

RHEL - How to back out a failed patch

Vathsa's- Linux - SysOps and DevOps

Local Yum Repository for Oracle Linux 8