Shiny app docker container not loading in browser

微笑、不失礼 提交于 2019-12-06 16:36:04

You don't need shiny-server.

add

app <- shinyApp(ui = ui, server = server)
runApp(app, host ="0.0.0.0", port = 80, launch.browser = FALSE)

to your R script and

EXPOSE 80
CMD ["R", "-e", "library(shiny); source('/root/pathToYourScript/script.R')"]

to your Dockerfile.

I had to first create a Rprofile.site file and place it in the same directory as the dockerfile and shinyapp. Then I created my own base image with all the necessary libraries for the app and called it from my dockerfile. Here is the final code:

Rprofile.site

local({
options(shiny.port = 3838, shiny.host = "0.0.0.0")
})

Dockerfile

FROM bimage_rpackages

# Copy the app to the image
RUN mkdir /root/shinyapp
COPY app/shinyapp /root/shinyapp

COPY app/Rprofile.site /usr/lib/R/etc/

# Make the ShinyApp available at port 3838
EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/root/shinyapp')"]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!