How do I install applications inside a Singularity sandbox container?

668 Views Asked by At

I am trying to install Miniconda (but could be any application that requires to for example /usr/local) in a Singularity sandbox container. I try the following:

singularity build --fakeroot --sandbox sandboxes/ubuntu:20.04 docker://ubuntu:20.04

This retrieves the container for me and builds it in sandboxes/ubuntu:20.04. So far, so good. Then I open shell in the container:

singularity shell --fakeroot -B ~:/homeoutside sandboxes/ubuntu\:20.04/

In the container, I try to install Miniconda:

bash /homeoutside/Miniconda3-latest-Linux-x86_64.sh -b -p /usr/local/miniconda3
mkdir: cannot create directory ‘/usr/local/miniconda3’: Read-only file system
ERROR: Could not create directory: '/usr/local/miniconda3'

The option "--fakeroot" makes me (fake) root inside the container, so I expected to be able to write to this path as root. Then I thought, maybe the it is the host system's /usr/local that is visible from inside the container. Then I tried "--cointain" to make sure this is not the case:

singularity shell --contain --fakeroot -B ~:/homeoutside sandboxes/ubuntu\:20.04/

Running the Miniconda set-up script still fails with the same message as above. What do I misunderstand about doing things as (fake) root inside a sandbox container?

1

There are 1 best solutions below

0
On

In order to make changes inside a sandbox you need to use the --writable flag when running your sandbox.