Our current Dockerfile utilizes Red Hat's Universal Base Image (UBI8) as the base image and performs a series of steps successfully. However, when attempting to port these steps to Ubuntu, we encounter issues. Here's an overview of what we currently do with Red Hat and what we're trying to achieve with Ubuntu:
We compile a list of Red Hat OS files and store them in OS-FILES.txt. These files are later copied to the image directory for inclusion in the scratch image.We prepare a "fake" RPM database for the scratch image, incorporating all packages necessary to obtain the files listed in OS-FILES.txt. This involves querying which RPM package contains each file, compiling a list of those packages, and adding them to PACKAGES.txt within the image directory.We download the RPM packages identified in the previous step. Although we only install package metadata and not package content, this download is still necessary.We install the metadata of the identified RPM packages into the "fake" RPM database within the image directory.Here's the snippet of the Dockerfile that performs these steps:
rpm --initdb --root "${IMAGE_DIR}" && \## For the files in OS-FILES.txt, query which rpm package contains them, build a list of# those packages and add them to PACKAGES.txt in the image directory.rpm --query --file $(cat "${IMAGE_DIR}/OS-FILES.txt") | sort -u | tee --append "${IMAGE_DIR}/PACKAGES.txt" && \## Download the rpm packages identified before - this is required although we are only going# to install package metadata but not package content.mkdir -p /package/ && \dnf download --destdir /package/ $(cat "${IMAGE_DIR}/PACKAGES.txt") && \## Install metadata of identified rpm packages to "fake" rpm database in the image directory.for p in $(cat "${IMAGE_DIR}/PACKAGES.txt"); \do \ rpm --install --root "${IMAGE_DIR}" --verbose --justdb --nodeps "/package/${p}.rpm"; \done
This approach works perfectly for Red Hat, but we're having trouble finding the equivalent steps or package management commands for Ubuntu. Could anyone provide guidance on how to achieve the same functionality in an Ubuntu-based Dockerfile? Specifically, we need to:
- Compile a list of Ubuntu OS files and their associated packages.
- Prepare a "fake" package database incorporating these packages.
- Download package metadata (not package content) and install it into the "fake" package database within the image directory.