闪亮的应用程序Docker容器未在浏览器中加载 [英] Shiny app docker container not loading in browser

查看:138
本文介绍了闪亮的应用程序Docker容器未在浏览器中加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对一个闪亮的应用程序进行了容器化,并尝试使用Kubernetes将其部署在GCP上,但是每次获取外部IP地址并将其加载到浏览器中时,都会出现无法访问此站点,连接被拒绝错误。因此,我尝试在本地主机上运行容器进行故障排除,现在我收到 127.0.0.1未发送任何数据。ERR_EMPTY_RESPONSE错误。我不知疲倦地在线搜索解决方案,但似乎没有任何效果。另外,所有解决方案都不是针对闪亮的应用程序Docker容器的。许多修复程序都提到了端口,但是我仍然被卡住。顺便说一句,我在Mac上安装了xampp。 xampp和我的docker容器是否可能试图共享同一端口,或者我的Docker文件代码是否有问题?请原谅,但我对容器还不陌生,到目前为止,还只是遵循文档程序。下面是我的Docker文件代码:

I containerised a shiny app and attempted to deploy it on GCP using Kubernetes but each time I obtain the external IP address and load it in the browser, I get the "this site cannot be reached connection refused" error. So I have attempted to run the container on my localhost to troubleshoot and now I get the "127.0.0.1 didn’t send any data. ERR_EMPTY_RESPONSE" error. I searched tirelessly online for a solution but nothing seems to work for me. Plus none of the solutions on are for a shiny app docker container. Many of the fixes mention the port but I am still stuck. I have xampp installed on my mac by the way. Is it possible that xampp and my docker container are attempting to share the same port or is there a problem with my Docker file code? Pardon me but I am new to containers and have only been following the documentation procedure up till now. Below is my Docker file code:

Dockerfile

# Install R version 3.5.1
FROM r-base:3.5.1

# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev

# Download and install ShinyServer (latest version)
RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os- 
build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt)  && \
wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os- 
build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && 
\
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb

# Install R packages that are required
# TODO: add further package if you need!
RUN R -e 

"install.packages(c('shiny','shinyjs','tools','foreign','XLConnect'), 
repos='http://cran.rstudio.com/')"

# Copy configuration files into the Docker image
COPY shiny-server.conf  /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/

# Make the ShinyApp available at port 80
EXPOSE 80

# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh

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

如果有人可以帮助我,我将不胜感激。

I would appreciate it if someone could assist me.

推荐答案

我必须首先创建一个Rprofile.site文件,并将其放置在与dockerfile和Shinyapp相同的目录中。然后,我创建了具有应用程序所有必需库的自己的基础映像,并从我的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')"]

这篇关于闪亮的应用程序Docker容器未在浏览器中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆