首先,我是docker世界中的新手。
我在使用闪亮的应用程序运行docker映像时遇到问题。通常,我在Windows中使用R-Studio,而我闪亮的应用程序可以与我的app.R文件中的“运行应用程序”一起正常工作。
首先,我不得不说我使用了此tuto,并且它具有简单的闪亮应用程序版本,效果很好。
但是对于我的应用程序来说,它有很多软件包,而且我想它们之间有很多依赖关系,但事实并非如此。当我在本地主机上浏览器时,出现以下消息:'发生了错误。应用程序无法启动。应用程序在初始化过程中退出了。。
在查找.log文件时,我有这种警告(我在R-Studio上有相同的消息):
Attaching package: ‘DT’
The following objects are masked from ‘package:shiny’:
dataTableOutput, renderDataTable
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
我对此并不十分担心(即使我想我可以做得更好并且删除一些依赖项),但是我的主要问题是,我想在这里:
.....
**Error in library(tm) : there is no package called ‘tm’
Calls: runApp ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
Execution halted
su: ignoring --preserve-environment, it's mutually exclusive with --login**
.....
似乎某些软件包无法安装在R版本的dockerfile中。 我不明白这是因为我在Windows中使用R 3.5.3,并将R 3.5.3放在dockerfile上。
我构建另一个容器,方法是删除dockerfile上的此tm包,并删除我的app.R上的“ library(tm)”,运行此新映像...,日志文件中的下一条错误消息为“ library(magick)” :没有名为“ magick”的软件包,依此类推...至少无法读取3个软件包。
这是我的整个dockerfile:
# Install R version 3.5.3
FROM r-base:3.5.3
# 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','readxl','stringr','DT','plyr','dplyr','ggplot2','plotly','scales','magrittr','rclipboard','shinythemes','Rmisc','data.table','qmap','wordcloud2','stringi','radarchart','leaflet','forcats','timevis','shinyWidgets','XLConnect','XLConnectJars','shinyalert','shinyjs','sqldf','sodium','glue','V8','lubridate'), 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"]
如您所见,我有很多要安装的软件包,我想它们之间的许多依赖关系可能不好。
这是我的Shiny-server.conf文件:
access_log /var/log/shiny-server/access.log tiny;
preserve_logs true;
# Define the user we should use when spawning R Shiny processes
run_as shiny;
# Define a top-level server which will listen on a port
server {
# Instruct this server to listen on port 80. The app at dokku-alt need expose PORT 80, or 500 e etc. See the docs
listen 80;
# Define the location available at the base URL
location / {
# Run this location in 'site_dir' mode, which hosts the entire directory
# tree at '/srv/shiny-server'
site_dir /srv/shiny-server;
# Define where we should put the log files for this location
log_dir /var/log/shiny-server;
# Should we list the contents of a (non-Shiny-App) directory when the user
# visits the corresponding URL?
directory_index on;
}
}
最后是我的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
exec shiny-server >> /var/log/shiny-server.log 2>&1
我的app文件夹包含我的app.R文件和一些excel(一些大型excel文件),也许这可能是一个坏因素...
预先感谢您的帮助