Configure a Local ISO-based Package Repository on a CentOS 7.2 VM

Consider the following scenario. You have downloaded the CentOS-7-x86_64-Everything-1511.iso from the CentOS Project or a mirror, used the ISO to create a VM in VMware Workstation, and now want to be able to access a package repository (repo) when you have no Internet access. Assume that a GNOME desktop is available on your CentOS VM and the VM is sized such that you have at least 8 Gb of free disk space.

Copy the IS0 to your CentOS VM by whatever method works for you. If you have VMware Tools installed, you can just drag and drop the file using your mouse. Make a directory, say /var/centos-iso, and place the ISO in that directory. Make another directory, say /var/centos72, and mount the ISO on this directory as a read-only loop device as shown below:

As you can see from the above image, if the mount worked, you can then cd to /var/centos72 and the contents of the ISO are available to you in the usual Unix tree-like structure.

To access the packages on the ISO using yum or dnf, you need to disable your existing repos (remember enabled=0?) and add a new repo which points to /var/centos72. Here is an example of such a repo.