【问题标题】:How to build/run container with writable file system using Singularity 3?如何使用 Singularity 3 构建/运行具有可写文件系统的容器?
【发布时间】:2019-05-28 11:16:32
【问题描述】:

我正在使用 Singularity 3.0 并尝试从 DockerHub 中提取容器映像并在大学集群上运行它。我关注this recipe 开始了。

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

容器进程启动,但当我尝试通过浏览器连接时,我收到以下错误日志。

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

好像容器中的文件系统是只读的。如何构建(或运行)容器以使容器的文件系统可写?

更新:

我能够让 RStudio Server 在大学集群上运行,如下所示。

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

这似乎可行,因为 Singularity 会自动将主机上的用户主目录挂载到容器中,并且我在上面将我的主目录重新定义为 my-project-directory

但是我仍然无法将 R 包安装到容器中,因为文件系统不可写。

> 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

原来的问题仍然存在:如何创建具有可写文件系统的 Singularity 3.* 容器?如果这是不可能的,解释为什么会很感激。

【问题讨论】:

    标签: docker rstudio-server singularity-container


    【解决方案1】:

    看了这个article,显然有解决包安装问题的办法:

    在你的主目录中创建一个.Renviron文件并设置R_LIBS_USER如下:

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

    这为我解决了包安装问题。

    【讨论】:

      【解决方案2】:

      您可以使用 --sandbox 选项创建沙盒文件夹。

      你也可以为奇异 2.5 创建一个虚拟机/流浪者

      【讨论】:

        【解决方案3】:

        在您的容器中尝试 --writable 标志:

        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
        

        【讨论】:

        • --writable 标志在 Singularity 3.0 中已被弃用,需要 sudo 权限(我在大学集群中没有)才能使用 Singularity 2.5。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-26
        • 2017-07-09
        • 1970-01-01
        • 2019-08-16
        • 2023-03-19
        • 1970-01-01
        相关资源
        最近更新 更多