Deploy shiny app in rocker/shiny docker

断了今生、忘了曾经 提交于 2020-06-25 03:30:08

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/44406631/deploy-shiny-app-in-rocker-shiny-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!