在 Docker 管道工中使用 R 预测包
Using R forecast package in Docker Plumber
我正在尝试为使用预测库的 R 脚本构建 docker 图像。我的 Dockerfile 如下所示:
FROM r-base:latest
RUN mkdir -p /usr/local/src/myscripts
COPY ./Plumber.R /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts
RUN R -e 'install.packages("plumber")'
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很简单,包含在第一行库中(预测)。
没有预测一切都很好,我可以 运行 容器。如上所述在 docker 文件和 Plumber.R 中添加预测时,容器的执行停止:
During startup - Warning messages:
1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘forecast’
2: package ‘forecast’ in options("defaultPackages") was not found
pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8000)
Error in library(forecast) : there is no package called ‘forecast’
Calls: ... -> source -> withVisible -> eval -> eval -> library
In addition: Warning message:
In readLines(file) : incomplete final line found on 'Plumber.R'
Execution halted
知道问题出在哪里吗?与所有其他 packages/libraries 一起工作时,只有预测会造成麻烦。
非常感谢
当我使用您的 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=...'
--------------------------------------------------------------------
所以 运行 apt-get install libcurl4-openssl-dev
在安装 R 包之前应该可以解决您的问题。
我正在尝试为使用预测库的 R 脚本构建 docker 图像。我的 Dockerfile 如下所示:
FROM r-base:latest
RUN mkdir -p /usr/local/src/myscripts
COPY ./Plumber.R /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts
RUN R -e 'install.packages("plumber")'
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很简单,包含在第一行库中(预测)。 没有预测一切都很好,我可以 运行 容器。如上所述在 docker 文件和 Plumber.R 中添加预测时,容器的执行停止:
During startup - Warning messages: 1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘forecast’ 2: package ‘forecast’ in options("defaultPackages") was not found pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8000) Error in library(forecast) : there is no package called ‘forecast’ Calls: ... -> source -> withVisible -> eval -> eval -> library In addition: Warning message: In readLines(file) : incomplete final line found on 'Plumber.R' Execution halted
知道问题出在哪里吗?与所有其他 packages/libraries 一起工作时,只有预测会造成麻烦。 非常感谢
当我使用您的 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=...'
--------------------------------------------------------------------
所以 运行 apt-get install libcurl4-openssl-dev
在安装 R 包之前应该可以解决您的问题。