Creating docker Image from centos 7 iso image

Hello Team I am trying to create my own docker image from centos 7 io i have written the docker file like this :

FROM scratch

Copy the CentOS 7 ISO contents to the container root

COPY CentOS-7-x86_64-DVD-2009.iso /tmp/centos.iso

Your customizations here (e.g., installing packages, setting configurations, etc.)

RUN yum -y install genisoimage-1.1.11-25.el7.x86_64.rpm

RUN mkdir /mnt/centos

RUN mount -o loop /tmp/centos.iso /mnt/centos

WORKDIR /mnt/centos

Example: Set the working directory and run a simple command

CMD [“/bin/sh”]

however I am getting an error while trying to do a docker build like this:

its failing with this error in this step : RUN yum -y install genisoimage-1.1.11-25.el7.x86_64.rpm I have tried to modify this line with the following options like:
RUN yum -y install genisoimage/RUN yum -y install mkisofs but nothing is working and its giving me this same error also I tried to modify the CMD line with tis option like CMD [“/bin/bash”] but nothing is working can anyone please help me on this ?

Looks like you are trying to install genisoimage using yum without the rpm package in the container. You can try to use a different approach to achieve this.

Something like this may work

FROM centos:7
COPY CentOS-7-x86_64-DVD-2009.iso /tmp/centos.iso
RUN mkdir /mnt/centos \
    && mount -o loop /tmp/centos.iso /mnt/centos \
    && yum -y install /mnt/centos/Packages/genisoimage-1.1.11-25.el7.x86_64.rpm \
    && umount /mnt/centos \
    && rm /tmp/centos.iso
WORKDIR /
CMD ["/bin/bash"]

Make sure to put the CentOS-7-x86_64-DVD-2009.iso file in the same directory as the Dockerfile before running the image build.

Hello I have tried but still it is failing with this error:

Please suggest

It looks like you’re trying to create a custom Docker image based on CentOS 7 using an ISO file and installing genisoimage inside the image. The error you’re encountering is likely due to the fact that the RPM package genisoimage-1.1.11-25.el7.x86_64.rpm is not available in the default CentOS repositories.

To resolve this issue, you can try the following steps:

  1. Update the package lists and install genisoimage from the official repositories:
  2. If you still need to use the RPM file directly, you need to make sure it’s available in the build context (the directory from which you’re running docker build) and then copy it to the appropriate location in the image before running the yum install command:
    Once you make the necessary changes, try running the docker build command again. If you encounter any further issues, please share the exact error message you’re getting, and we’ll be happy to assist you further. Happy Dockerizing! :whale:

I think you’ll find it’s the ‘mount’ cmd that is failing:

[root@84b42168dd57 tmp]# mount -o loop /tmp/centos.iso /mnt/centos
mount: /mnt/centos: mount failed: Unknown error -1

Having same issue building my image. No solution yet…