Reputation: 616
I am trying to build a docker image for a R-script which is using the forecast library. My Dockerfile looks like this:
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"]
The Plumber.R is very simple and contains in the first line library(forecast). Without forecast everything works nicely and I can run the container. When adding forecast in the dockerfile as above and in Plumber.R the execution of the container stops with:
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
Any idea what is the issue? With all other packages/libraries it works only forecast is making trouble. Many thanks in advance
Upvotes: 1
Views: 1271
Reputation: 26823
When I build a container using your Docker file, I get some messages:
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
The root of these messages is the following error:
------------------------- 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=...'
--------------------------------------------------------------------
So running apt-get install libcurl4-openssl-dev
before installing the R packages should fix your issue.
Upvotes: 2