Hprc banner tamu.png

SW:Singularity:Examples

From TAMU HPRC
Revision as of 12:43, 14 August 2018 by J-perdue (talk | contribs) (Building an image on your Fedora 28 workstation)
Jump to: navigation, search

Examples

Fedora 28

Building an image on your Fedora 28 workstation

Create a "sandbox"
  • start a root shell, but maintain location (you will need it for most of the next steps so might as well do it now to avoid all the password retypes for sudo)
sudo su
  • create a Singularity sandbox from one of Fedora's Docker images
singularity build --sandbox Fedora28-HPRCLAB.sandbox docker://fedora:28
  • create a list of packages to install into the image and place in /root. In this case we use the HPRCLAB/Fedora28 workstations current list of software. So on the workstation/host (not in the image):
rpm -qa --qf "%{NAME}\n" | sort > /root/rpmlist

which results in something that looks like this:

[root@hprclab4 ~]# head -5 /root/rpmlist 
a2ps
a52dec
aajohan-comfortaa-fonts
aalib-libs
aalto-xml
  • while still in the host sudo/root shell update the image using the --writable shell in the sandbox (requires sudo for next steps)
singularity shell --writable Fedora28-HPRCLAB.sandbox/
  • Install the RPMFUSION repos (needed for below)
dnf -y install\
 https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-28.noarch.rpm\
 https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-28.noarch.rpm
  • populate the sandbox with all the RPMs (we do them in groups at first in case there a problems and then do all to see what those problems were. (get a snack, take a walk... it can take awhile)
for x in {a..z} ; do
  dnf -y install `grep ^$x /root/rpmlist`
done
dnf -y install `cat /root/rpmlist`

or maybe

for x in `cat /root/rpmlist` ; do
  dnf -y install $x
done

There will still be packages that have "No match" due to not including the repos for them.

  • do NOT add users with useradd... if you do, be sure not to add your NetID or things will break.
  • create bind directories for interfacing with HPRC clusters (Note: have to do this now while still in sudo shell)
mkdir /scratch /work
  • once you are happy with the sandbox log out from it (logout/exit/Ctrl-D).
Create an image (.img)
  • To make an .img file that provides space for the user to work in (e.g. download/install software). These steps do not require sudo since they don't really create anything in the image. This example is for a 20GB /.
singularity image.create Fedora28-HPRCLAB.img # create .img file
singularity image.expand -s 20480 Fedora28-HPRCLAB.img # expand to 20GB, get another snack while you wait

Note: works because there is no real filesystem yet [some ext3/4 filesystems seem to have a problem with expand]

  • Now import the sandbox into the 20GB image (more snacks/time)
sudo tar -cvf - -C Fedora28-HPRCLAB.sandbox/ . | sudo singularity image.import Fedora28-HPRCLAB.img

(see the last/tar example in 'singularity image.import --help')

Test on host build system
  • open a non-sudo shell and see if you can do "things"
singularity shell Fedora28-HPRCLAB.img

Using your image on HPRC clusters =