Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy shiny app in rocker/shiny docker

Well, I'm new at Docker and I need to implement a Shiny app in a Docker Container.

I have the image from https://hub.docker.com/r/rocker/shiny/, that includes Shiny Server, but I don't know how to deploy my app in the server.

I want to deploy the app in the server, install the required packages for my app into the Docker, save the changes and export the image/container.

As I said, I'm new at Docker and I don't know how it really works.

Any idea?

like image 945
JFernandez Avatar asked Jun 07 '17 07:06

JFernandez


Video Answer


2 Answers

I guess you should start by creating a Dockerfile in a specific folder which would look like something like this :

FROM rocker/shiny:latest

RUN  echo 'install.packages(c("package1","package2", ...), \
repos="http://cran.us.r-project.org", \
dependencies=TRUE)' > /tmp/packages.R \
  && Rscript /tmp/packages.R

EXPOSE 3838
CMD ["/usr/bin/shiny-server.sh"]

Then go into this folder and build your image, giving it a name by using this command :

docker build -t your-tag .

Finally, once your image is built you can create a container, and if you don't forget to map the volume and the port, you should be able to find it at localhost:3838 with the following command launched from the folder containing the srv folder :

docker run --rm -p 3838:3838 -v $PWD/srv/shinyapps/:/srv/shiny-server/ -v $PWD/srv/shinylog/:/var/log/shiny-server/ your-tag

As said in the Docker documentation at the following address https://hub.docker.com/r/rocker/shiny/, you might want to launch it in detached mode with -d option and map it with your host's port 80 for a real deployment.

like image 192
Sacha Avatar answered Oct 27 '22 07:10

Sacha


The link(https://hub.docker.com/r/rocker/shiny/) covers how to deploy the shiny server. Simplest way would be: docker run --rm -p 3838:3838 rocker/shiny

If you want to extend shiny server, you can write your own Dockerfile and start with shiny image as base image.(https://docs.docker.com/engine/reference/builder/)

Dockerfile: FROM rocker/shiny:latest

like image 31
Sreeni Avatar answered Oct 27 '22 07:10

Sreeni