Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
biobai opened this issue Apr 10, 2024 · 4 comments
Open

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

biobai opened this issue Apr 10, 2024 · 4 comments
Labels

Comments

@biobai
Copy link

biobai commented Apr 10, 2024

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
Copy link
Member

eitsupi commented Apr 10, 2024

@biobai
Copy link
Author

biobai commented Apr 11, 2024

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
Copy link

karcaw commented Apr 23, 2024

have you tried running it with a writable tmp?

apptainer run --writable-tmpfs shiny-verse.sif

@nathanweeks
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants