'Edit runscript of singularity .sif container after building
I have build a singularity container and uploaded it to my HPC service.
Is there a way to change the runscript of the .sif file without rebuilding the whole container? I have a shell on the service.
From my understanding of singularity this should be possible but I cant find out how.
Solution 1:[1]
You can edit the file <YOUR_CONTAINER.sif>/singularity
as it contains the runscript.
The same can be done for the environment with the file <YOUR_CONTAINER.sif>/environment
.
Solution 2:[2]
You can convert a SIF file to a (writable) sandbox which is indeed a directory:
sudo singularity build --sandbox <SANDBOX> <CONTAINER>.sif
Then you can "get into" the sandbox and modify things there (note the --writable
flag and the need for sudo
):
sudo singularity shell --writable <SANDBOX>
Or you can edit <SANDBOX>/singularity
or <SANDBOX>/environment
as suggested by Quentin.
Additional goodies can be found in the <SANDBOX>/.singularity.d
directory. Such as the Singularity
file which is the recipe the container was built from.
Once you are happy with the changes you can convert the sandbox back to a (new) SIF file:
sudo singularity build <NEW_CONTAINER>.sif <SANDBOX>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Quentin Possamaï |
Solution 2 |