rocker-org / rocker-versioned2

Run current & prior versions of R using docker. rocker/r-ver, rocker/rstudio, rocker/shiny, rocker/tidyverse, and so on.
https://rocker-project.org
GNU General Public License v2.0
390 stars 163 forks source link

rstudio: mounting read-only directory #777

Closed nick-youngblut closed 3 months ago

nick-youngblut commented 3 months ago

Container image name

rocker/rstudio:4.3.1

Container image digest

No response

What operating system related to this question?

Linux

System information

Question

I would like to mount my working directory and also a NAS directory mounted on the VM that I'm using (/mnt/NAS/).

My docker run command:

docker run -d --rm -it \
  -e PASSWORD="${PASSWORD}" \
  -e ROOT=true \
  -p 9801:8787 \
  -e USERID=$(id -u) \
  -e GROUPID=$(id -g) \
  -v `pwd`:/home/rstudio/workspace \
  -v /mnt/NAS/LabDevices/NGS-210-21:/home/rstudio/NGS-210-21 \
  rocker/rstudio:4.3.1

When I include -v /mnt/NAS/LabDevices/NGS-210-21:/home/rstudio/NGS-210-21, the init command seems to fail (but no error message written to the console), and I cannot access the Rstudio login screen; however, I can access the login if that NAS mount point is not included.

I can mount /mnt/NAS/LabDevices/NGS-210-21 for other docker containers, so this appears specific to the setup of init in rocker/rstudio:4.3.1. I don't see any docs on dealing with mounting read-only directories rocker/rstudio.

Any ideas on what the problem is?

eitsupi commented 3 months ago

Maybe https://rocker-project.org/images/versioned/rstudio.html#userid-and-groupid?

The UID and GID of the default non-root user can be changed as follows:

docker run --rm -ti -e USERID=1001 -e GROUPID=1001 -p 8787:8787 rocker/rstudio

Warning If these are set, ownership of the /home/rstudio directory in the container is updated by the root user. This will also overwrite the ownership of any files that are bind-mounted under the /home/rstudio directory.

nick-youngblut commented 3 months ago

@eitsupi how is that different from:

  -e USERID=$(id -u) \
  -e GROUPID=$(id -g) \

...which I'm already using?

eitsupi commented 3 months ago

There is no difference. I think that by setting them, additional behavior is occurring, causing a malfunction. Perhaps that means you shouldn't mount the bind under the home directory.

benz0li commented 3 months ago

@nick-youngblut How about using /mnt in the container, too?

ℹ️ Filesystem Hierarchy Standard > 3. The Root Filesystem > 3.12. /mnt : Mount point for a temporarily mounted filesystem

What is the reason for explicitly mounting within /home/rstudio?

nick-youngblut commented 3 months ago

@benz0li that solution works. Thanks!

What is the reason for explicitly mounting within

For users with less computational skills, presenting all mounted directories in /home/rstudio is easier for them than /mnt, which is not (easily) shown in the Rstudio file browser.

eddelbuettel commented 3 months ago

@nick-youngblut I think this has come up many times here before, so please feel free to search past issues. When one runs RStudio it keeps state below $HOME which is in conflict with mounting that directory read-only.

benz0li commented 3 months ago

For users with less computational skills, presenting all mounted directories in /home/rstudio is easier for them than /mnt, which is not (easily) shown in the Rstudio file browser.

@nick-youngblut You could conditionally symlink ~/mnt to /mnt by adding something like

if [ "$(ls -A /mnt 2>/dev/null)" != "" ]; then
    runuser -u "${USER}" -g "$(id "${USER}" -g -n)" -- ln -snf /mnt "${USERHOME}"/mnt
fi

in scripts/init_userconf.sh.