How to build/run container with writable file system using Singularity 3?
Asked Answered
G

3

7

I am using Singularity 3.0 and trying to pull a container image from DockerHub and run it on a university cluster. I followed this recipe to get started.

singularity pull --name rstudio-3.5.2.sif docker://rocker/rstudio:3.5.2
singularity exec --bind example-project-1/:/home/rstudio/ rstudio-3.5.2.sif rserver --www-port 8787

The container process starts but when I try to connect via a browser I get the following error log.

01 Jan 2019 12:07:22 [rsession-pughdr] ERROR system error 30 (Read-only file system) [path=/home/pughdr/.rstudio, target-dir=]; OCCURRED AT: rstudio::core::Error rstudio::core::FilePath::createDirectory(const string&) const /home/ubuntu/rstudio/src/cpp/core/FilePath.cpp:846; LOGGED FROM: rstudio::core::FilePath rstudio::core::system::userSettingsPath(const rstudio::core::FilePath&, const string&) /home/ubuntu/rstudio/src/cpp/core/system/PosixSystem.cpp:486
01 Jan 2019 12:07:22 [rsession-pughdr] ERROR system error 30 (Read-only file system) [path=/home/pughdr/.rstudio, target-dir=]; OCCURRED AT: rstudio::core::Error rstudio::core::FilePath::createDirectory(const string&) const /home/ubuntu/rstudio/src/cpp/core/FilePath.cpp:846; LOGGED FROM: int main(int, char* const*) /home/ubuntu/rstudio/src/cpp/session/SessionMain.cpp:1689

Seems that the file system in the container is only read-only. How do I build (or run) the container such that the container's file system is writable?

Update:

I was able to get the RStudio Server running on the university cluster as follows.

singularity exec --home my-project-directory rstudio-3.5.2.sif rserver --www-port 8787

This seems to work because Singularity automatically mounts the user's home directory on the host into the container and I redefined my home directory to be my-project-directory in the above.

However I still cannot install R packages into the container as the file system is not writable.

> install.packages(c("plyr", "dply", "tidyr", "ggplot2"))
Installing packages into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages :
  'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (yes/No/cancel) cancel
Error in install.packages : unable to install packages

Original question still stands: how can I create a Singularity 3.* container that has a writable filesystem? If this is not possible, explanation as to why would be appreciated.

Galileo answered 1/1, 2019 at 13:0 Comment(0)
D
2

Reading in this article, apparently there is a solution to the problem concerning package installation:

Create an .Renviron file in your home directory and set R_LIBS_USER as follows:

# User-installed R packages go into their home directory
echo 'R_LIBS_USER=~/R/%p-library/%v' >> ${HOME}/.Renviron

This solved the package-installation-issue for me.

Dissociate answered 1/9, 2020 at 20:24 Comment(0)
U
1

try --writable flag in your container:

singularity build --writable rstudio-3.5.2.sif docker://rocker/rstudio:3.5.2

singularity exec --writable --bind example-project-1/:/home/rstudio/ rstudio-3.5.2.sif rserver --www-port 8787
Urethroscope answered 1/1, 2019 at 17:31 Comment(2)
The --writable flag was deprecated in Singularity 3.0 and requires sudo rights (which I don't have on university cluster) for Singularity 2.5.Galileo
The --writable-tmpfs replicates the docker behaviour: "makes the file system accessible as read-write with non persistent data (with overlay support only)"Fahrenheit
L
0

You can create a sandbox folder with --sandbox option .

Also you probably can create a Virtual Machine / vagrant for singularity 2.5

Leora answered 1/8, 2019 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.