Building a container for tdespec
NOTE: This method may need to be updated soon as singularity has changed it’s name to
apptainer. Some of the commands below (such as the remote login
and pull
functions) don’t work when using the apptainer module on HAWK. So for now use the
singularity module.
Setup
- Go to the Sylabs site and create an account. I used my Gitlab credentials to sign in.
- Create a time sensitive access token. Navigate to the
access token
tab, add a label for your access token in the command box (I called mine ‘hawk’) and copy the access token to your clipboard. This token will be valid for one month. On HAWK
: load the sigularity modulemodule load singularity-ce/3.10.2
(don’t use default singularity module as it is a symlink for apptainer).- Type
singularity remote login
and paste access token in when prompted and hit enter. - If this is successful you should see
INFO: Access Token Verified!
. Access status can be checked at any time usingsingularity remote status
. When your access token has run out it will sayFATAL: error response from server: Invalid Credentials
. So you will need to generate a new access token and repeat the steps above.
Create a container
Rather than create an entire container from scratch, it’s best to find a pre-existing container that
contains the OS / packages that you need that you can add to. Here, I needed a container to run R in
a conda / snakemake environment as I was often encountering dependency clashes when trying to load R
packages. As tdespec
uses some bioconductor packages I decided to use the bioconductor_docker
image which contains the basic
R and bioconductor packages. It is then possible to install the additional R libraries you need in
the %post
section of the definition file.
To build the container you need a definition file
. Navigate to the remote builder
tab
in your Sylabs repository and copy the following into the Definition file
section.
(The definition file
can be much more complex than this but this is all we need. To build the base container we
only need the first two lines!)
Bootstrap: docker
From: bioconductor/bioconductor_docker:devel
%labels
Version v0.0.1
%help
This is container to run tdespec
%post
R --no-echo -e 'remotes::install_github("Dazcam/tdespec")'
Then name your container in the Repository
box (I called mine ‘containers/tdespec’) and hit
submit. The container takes ~50 mins to build.
Once built, copy the pull command at the top of the page and paste it into the command line to download the container.
singularity pull library://dazcam/containers/tdespec
Running commands in the container.
To run R within the container use the following:
singularity exec tdespec_latest.sif R
Sections of a definition file
- %environment: Define bash variables within the container
- %post: Section to build packages above the bootstrapped environment. We could install R and python here for example.
- %runscript: Add scripts here to test the programs you just installed in
%post
Additional links:
Move on to Build a container in layers, or back to index page.