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
419 stars 180 forks source link

How to use rocker-org/shiny in singularity #781

Open biobai opened 7 months ago

biobai commented 7 months ago

Container image name

shiny_4.3.3

Container image digest

No response

What operating system related to this question?

Linux

System information

No response

Question

I use singularity to run shiny. podman pull docker.io/rocker/shiny podman save --format oci-archive --output shiny.tar docker.io/rocker/shiny singularity build shiny.sif oci-archive://shiny.tar singularity run shiny.sif s6-mkdir: warning: unable to mkdir /var/run/s6: Read-only file system

I found this tutorial about rstudio (https://rocker-project.org/use/singularity.html). But no tutorial about shiny was provided. Any suggestions would be highly appreciated.

eitsupi commented 7 months ago

Have you tried this? https://rocker-project.org/images/versioned/shiny.html#run-by-non-root-user

biobai commented 7 months ago

Have you tried this? https://rocker-project.org/images/versioned/shiny.html#run-by-non-root-user

It works in the beginning.

podman run --rm -ti -p 3838:3838 docker.io/rocker/shiny [s6-init] making user provided files available at /var/run/s6/etc...exited [s6-init] ensuring user provided files have correct perms...exited 0. [fix-attrs.d] applying ownership & permissions fixes... [fix-attrs.d] done. [cont-init.d] executing container initialization scripts... [cont-init.d] done. [services.d] starting services [services.d] done.

*** warning - no files are being watched *** [2024-04-11T02:07:35.110] [INFO] shiny-server - Shiny Server v1.5.17.960 (Node.js v12.20.0) [2024-04-11T02:07:35.114] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf" [2024-04-11T02:07:35.152] [WARN] shiny-server - Running as root unnecessarily is a security risk! You could be running more securely as non-root. [2024-04-11T02:07:35.156] [INFO] shiny-server - Starting listener on http://[::]:3838

But it looks like that the same error happens when I run shiny by non-root user, which is the same as in singularity.

podman run --rm -ti -p 3838:3838 --user shiny docker.io/rocker/shiny s6-mkdir: warning: unable to mkdir /var/run/s6: Permission denied

karcaw commented 7 months ago

have you tried running it with a writable tmp?

apptainer run --writable-tmpfs shiny-verse.sif
nathanweeks commented 7 months ago

For SingularityCE (or Apptainer), the following seems sufficient to launch shiny server (accessible from http://localhost:3838 ; the sed command can be extended to modify the port specified in shiny-server.conf if a different port is desired)

#!/bin/sh

set -o errexit
SCRATCH=$(mktemp -d)
singularity exec shiny_4.3.3.sif sed -e "/run_as/s/shiny/$(id -un)/" /etc/shiny-server/shiny-server.conf > ${SCRATCH}/shiny-server.conf

## uncomment to serve your own directory of shiny apps on the host
# export SINGULARITY_BIND=${PWD}/my-apps:/srv/shiny-server

singularity exec \
  --cleanenv \
  --containall \
  --bind ${SCRATCH}/shiny-server.conf:/etc/shiny-server/shiny-server.conf \
  --workdir ${SCRATCH} \
  --scratch /var/log \
  --scratch /var/lib/shiny-server/bookmarks \
  shiny_4.3.3.sif shiny-server