r - 使用 Docker 部署 R 闪亮的应用程序
问题描述
我正在尝试使用 Docker 部署 R 闪亮的应用程序。但是我不断收到以下错误,即应用程序所需的软件包未安装在 docker 上,即使我使用 Dockerfile 脚本安装了它们
'/var/log/shiny-server//shiny-server-shiny-20210531-160002-46437.log' has been created
***/var/log/shiny-server//shiny-server-shiny-20210531-160002-46437.log ***
su: ignoring --preserve-environment, its mutually exclusive with --login
Error in library(shinydashboard) :
there is no package called ‘shinydashboard’
Calls: runApp ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
Execution halted
我的 Dockerfile 看起来像这样
FROM rocker/r-ver:3.6.3
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
xtail \
wget
#RUN sudo su - -c "R -e \"install.packages(c('plyr'), repos='http://cran.rstudio.com/')\""
# Download and install shiny server
RUN wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION -O
"version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-
server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb && \
. /etc/environment && \
R -e "install.packages(c('shiny',
'plotly','shinydashboard','dplyr','ggplot2','DT','shinyjs','sodium','shinyWidgets','magrittr','tidyr','shinythemes'), repos='$MRAN')" && \
cp -R /usr/local/lib/R/site-library/shiny/examples/* /srv/shiny-server/ && \
chown shiny:shiny /var/lib/shiny-server
EXPOSE 3838
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
我的 shiny-server.sh 文件如下所示:
#!/bin/sh
# Make sure the directory for individual app logs exists
mkdir -p /var/log/shiny-server
chown shiny.shiny /var/log/shiny-server
if [ "$APPLICATION_LOGS_TO_STDOUT" != "false" ];
then
# push the "real" application logs to stdout with xtail in detached mode
exec xtail /var/log/shiny-server/ &
fi
# start shiny server
exec shiny-server 2>&1
解决方案
推荐阅读
- linux - 使用 Bash 跳过文件中的第一个匹配项
- javascript - 窗口在所有分辨率下滚动到页脚时的事件 - jquery
- javascript - 如何从快速分页中的 URL 中删除限制参数?
- asp.net-mvc - 在 tinymce 编辑器中 - 在编号列表中单击时它不起作用
- java - 如何在电子票、手机票和自助票之间进行选择以点击它
- java - 注释和异常
- html - 容器在我的 Vue Swiper 中没有内联
- delphi - E2555 无法捕获符号“Self”
- kubernetes - GKE 集群的权限
- regex - 无法在 perl6 中编写语法来解析带有特殊字符的行