I wanted to use singularity for my own selfish purposes; when presenting my research I want it to be easy for someone else to try.
sudo apt install singularity
.
I wanted a module. You need the following packages:
build-essential libssl-dev uuid-dev libgpgme11-dev libseccomp-dev pkg-config squashfs-tools
golang-1.10
(I only tried on Ubuntu)
Then you download the source in just the right place:
export GOPATH=/where/I/keep/source
PREFIX=/packages/singularity/3.1.0
mkdir -p ${GOPATH}/src/github.com/sylabs && \
cd ${GOPATH}/src/github.com/sylabs && \
git clone https://github.com/sylabs/singularity.git && \
cd singularity
git checkout v3.1.0
./mconfig -p $PREFIX && \
cd ./builddir && \
make && \
sudo make install
Then, I made a module file like so:
#%Module########################################
## Singularity
set _module_name [module-info name]
module-whatis "Singularity version 3.1.0 built using GO language version 1.10.1 linux/amd64"
set SWTOP /usr/local/packages/singularity/3.1.0
prepend-path PATH $SWTOP/bin
sudo singularity build epg.sif Singularity
Watch it fail, then try again and again.
You can bind
that directory so when creating the singularity image, it can be seen:
sudo singularity build --bind /opt/local/bin:/packages/something/bin ...
will mount /packages/...
into /opt/local/bin
into the container.
- /home/$USER, /tmp, and $(pwd) are bound by default.
singularity shell epg.sif
singularity exec epg.sif
Singularity images are immutable. This is nice for reproducibility, but what if I made a mistake on the image and you want to change it a bit? Well hopefully you can just edit the definition file, but if not you must create an overlay.
mkdir overlay
sudo singularity shell --overlay overlay/ ubuntu.sif
<do something>
# Then you need to use the --overlay flag every time
- Each section starts you in a different directory!
%post
- starts in/
%runscript
- starts in your current working directory%environment
- ends up setting stuff in/.singularity.d/env/
or something? I'm not sure, but one thing I am sure of is you can't "source" things (e.g.. script.sh
doesn't work)%test
- Starts in current working directory
- You're running
sh
notbash
. As such, you can't doexport VAR=val
. You have to do
VAR1=val1
VAR2=val2
export VAR1 VAR2
- You can see some stuff from your local filesystem. Namely,
/tmp
,$HOME
,/proc
,/sys
,/dev
, and$(pwd)
.- But you can't write to any of them while inside the container! Which is nice, that's what containers are for. You can write but everything gets lots when you exit.
- Note
/usr/local/bin
isn't included in this list.