在Docker Plumber中使用R预测包

时间:2018-01-29 14:59:30

标签: r docker dockerfile plumber

我正在尝试为使用预测库的R脚本构建一个docker镜像。我的Dockerfile看起来像这样:     来自r-base:最新 运行mkdir -p / usr / local / src / myscripts COPY ./Plumber.R / usr / local / src / myscripts WORKDIR / usr / local / src / myscripts RUN R -e' install.packages("水管工")' RUN R -e' install.packages(" forecast")' EXPOSE 8000 ENTRYPOINT [" R"," -e"," pr< - plumber :: plumb(commandArgs()[4]); pr $ run(host =' 0.0.0.0',port = 8000)"] CMD [" Plumber.R"] Plumber.R非常简单,包含在第一行库中(预测)。 没有预测一切都很好,我可以运行容器。如上所述在dockerfile中添加预测时,在Plumber.R中,容器的执行将停止:   启动期间 - 警告消息:   1:在库中(包,lib.loc = lib.loc,character.only = TRUE,logical.return = TRUE,:     没有名为'预测'的包   2:未找到选项(" defaultPackages")中的包'预测'   pr< - plumber :: plumb(commandArgs()[4]); pr $ run(host =' 0.0.0.0',port = 8000)   库中的错误(预测):没有名为'forecast'的包   电话:... - >来源 - > withVisible - > eval - > eval - >图书馆   另外:警告信息:   在readLines(文件)中:在' Plumber.R'上找到不完整的最终行。   执行停止 不知道是什么问题?对于所有其他软件包/库,只有预测才会出现问题。 提前谢谢了

1 个答案:

答案 0 :(得分:2)

当我使用Docker文件构建容器时,我会收到一些消息:

Warning messages:
1: In install.packages("forecast") :
  installation of package ‘curl’ had non-zero exit status
2: In install.packages("forecast") :
  installation of package ‘TTR’ had non-zero exit status
3: In install.packages("forecast") :
  installation of package ‘quantmod’ had non-zero exit status
4: In install.packages("forecast") :
  installation of package ‘tseries’ had non-zero exit status
5: In install.packages("forecast") :
  installation of package ‘forecast’ had non-zero exit status

这些消息的根目录是以下错误:

------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fedora, CentOS, RHEL)
 * csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------

因此,在安装R软件包之前运行apt-get install libcurl4-openssl-dev应该可以解决您的问题。