Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Download and save a basic CentOS image from Docker : "singularity pull docker://centos:centos7.7.1908"with the following command. This command will save a file /tmp/centos_centos7.7.1908.sif to /tmp.

singularity pull docker://centos:centos7.7.1908

  • Extract the squashfs image from the saved .sif file. A .sif has several objects inside, which you can exam by using "singularity sif list /tmp/centos_centos7.7.1908.sif" command. The squashffs squashfs image we need is usually the 3rd object. Extract and save it with command "command 

singularity sif dump 3 /tmp/centos_centos7.7.1908.sif > /tmp/centos_centos7.7.1908.sqsh

...

  • Unpack the files from the squashfs image: ". This will create a sub-directory squashfs-root, which contains the OS files. All files under this directory are own by you, not root.

/bin/unsquashfs \-no-xattrs /tmp/centos_centos7.7.1908.sqsh

  • Singularity can use the files in /tmp/squashfs-root as an "image" (Singularity sandbox image). But one needs to change a few things in order to install additional rpms via yum in the image. So do this: 
    • Fix a few directory permission issue: 

cd /tmp/squashfs-root; find usr bin lib* etc root var -type d -exec chmod u+w {} \;

    • By default, yum checks if the user is root, and will refuse to install anything if it is not. So edit /tmp/squashfs-root/usr/share/yum-cli/yumcommands.py and change the following code and comment out the relevant code (in red)

 

def checkRootUID(base):
    """Verify that the program is being run by the root user.

    :param base: a :class:`yum.Yumbase` object.
    :raises: :class:`cli.CliError`
    """
    # if base.conf.uid != 0:
    # base.logger.critical(_('You need to be root to perform this command.'))
    # raise cli.CliError

 

  • After the above change, you can start using the image and installing rpms, such as

singularity shell /tmp/squashfs-root

singularity exec \-w --no-home /tmp/squashfs-root yum install git

 

 

Step-by-step guide

 

Info

...