我为一个R Shiny应用程序构建了一个Docker镜像,并在Windows 10 Home上使用Docker Toolbox运行了相应的容器。当试图使用我的Web浏览器打开应用程序时,仅显示索引。我不知道为什么应用程序没有执行。日志向我展示了以下信息:
我的Docker文件如下所示:
*** warning - no files are being watched ***
[2019-08-12T15:34:42.688] [INFO] shiny-server - Shiny Server v1.5.12.1 (Node.js v10.15.3)
[2019-08-12T15:34:42.704] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2019-08-12T15:34:43.100] [INFO] shiny-server - Starting listener on http://[::]:3838
我已经通过执行以下命令指定了应用主机到容器的路径,该命令引用了一个 Docker Hub 镜像:
docker run --rm -p 3838:3838 -v /C/Docker/App/:/srv/shinyserver/ -v /C/Docker/shinylog:/var/log/shiny-server/ didsh123/ps_app:heatmap
我的Docker文件如下所示:
# get shiny serves plus tidyverse packages image
FROM rocker/shiny-verse:latest
# system libraries of general use
RUN apt-get update && apt-get install -y \
sudo \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libssh2-1-dev
##Install R packages that are required--> were already succesfull
RUN R -e "install.packages(c('shinydashboard','shiny', 'plotly', 'dplyr', 'magrittr'))"
#Heatmap related packages
RUN R -e "install.packages('gpclib', type='source')"
RUN R -e "install.packages('rgeos', type='source')"
RUN R -e "install.packages('rgdal', type='source')"
# copy app to image
COPY ./App /srv/shiny-server/App
# add .conf file to image/container to preserve log file
COPY ./shiny-server.conf /etc/shiny-server/shiny-server.conf
##When run image and create a container, this container will listen on port 3838
EXPOSE 3838
###Avoiding running as root --> run container as user instead
# allow permission
RUN sudo chown -R shiny:shiny /srv/shiny-server
# execute in the following as user --> imortant to give permission before that step
USER shiny
##run app
CMD ["/usr/bin/shiny-server.sh"]
当我在浏览器中输入docker IP地址和端口号时,应该能够运行应用程序,但是只有主页显示出来。我使用以下语句:
http://192.168.99.100:3838/App/
我很高兴能得到任何提示或建议。因为我是 Docker 的新手,所以非常需要详细的解释。
/etc/shiny-server/shiny-server.conf
,但是当您复制COPY ./shiny-server.conf.txt /etc/shiny-server/
时,会复制.txt
文件。这意味着您的应用程序正在使用默认配置,而不是您复制到镜像中的文件。 - Avinash ReddyUSER appuser
以减轻日志中的安全风险警告。参考:https://medium.com/@mccode/processes-in-containers-should-not-run-as-root-2feae3f0df3b - Avinash ReddyCOPY ./shiny-server.conf /etc/shiny-server/
。您正在尝试将一个 .txt 文件复制到 /etc/shiny-server 目录中,请检查本地目录中的文件扩展名。 - Avinash Reddy