Dieter Menne Dieter Menne - 2 months ago 28
R Question

RStudio and Shiny in one dockerfile

I am looking into

to distribute a
application that also requires RStudio. The primary goal is easy installation at hospitals under Windows. Everything that requires character input into black boxes will certainly fail during installation by non-IT people.

My previous attempts used vagrant, but installing vagrant alone proved to be a hurdle.

repository, has an RStudio and a Shiny , and for my own installation both work together. However, I would like to create a combined application for easier installation.

What is the recommended workflow? Start with RStudio, and manually add Shiny?
Or merge the dockerfiles code from both Rockers, starting with r-base? Or use compose tool?


Interesting question, but I'm not sure I understand the advantage of having the shiny-server and the rstudio-server instances served from the same container.

Is the purpose so that the two containers share the same R libraries (e.g. so a package doesn't need to be installed separately on each) or merely to have one docker container instead of two? Just having to run two docker commands instead of one doesn't seem that onerous, but maybe I'm underestimating.

Sharing the underlying libraries seems like a valid objective though, and I don't think there's an ideal solution available yet.

I feel the most docker-esque solution would be to do this via container orchestration/compose tool as you mention. This is the usual way to combine separate services (e.g. web server and database) without building one on top of the other.

Unfortunately, the tooling for orchestration based on mapping volumes is not nearly as well developed as it is for mapping ports.

Imagine running the rstudio as a volume container:

docker run --name rstudio -v /usr/local/lib/R/site.library rocker/rstudio true

(If you wanted RStudio access at the same time, one could instead run this as:)

docker run --name rstudio -dP -v /usr/local/lib/R/site.library rocker/rstudio

You can then use the the site.library from the rstudio container in place of that on the shiny container with a command like:

docker run --volumes-from rstudio -dP rocker/shiny

Unfortunately, this clobbers the site.library of the shiny container. To work around this, you'd want to mount the library of the rstudio container in a different place, but there's no easy syntax for this like we already have with port links. It can be done though, see:

How to map volume paths using Docker's --volumes-from?

There's an open thread on this issue in the rocker repo too.