我正在尝试使用Dockerfile安装R软件包。
我安装了映像Rocker/Rstudio。
Dockerfile的内容为:
# Base image https://hub.docker.com/r/rocker/rstudio
FROM rocker/rstudio:latest
## Create directories
RUN mkdir -p /rstudio
RUN mkdir -p /rscripts
##Install R packages
RUN R -e "install.packages(c('rvest', 'jsonlite', 'data.table' ,'stringr'), repos = 'http://cran.us.r-project.org')"
然后,我建立自己的形象:docker build -t my_r_image .
生成图像,但未安装软件包,因为出现此警告:
将软件包安装到“ / usr / local / lib / R / site-library”(因为“ lib”为 未指定)警告:无法访问存储库的索引 http://cran.us.r-project.org/src/contrib:无法打开URL 'http://cran.us.r-project.org/src/contrib/PACKAGES'
我尝试将http://cran.us.r-project.org
替换为= 'http://cran.rstudio.com/')"
,但收到类似的错误消息,提示它无法访问存储库的索引。
有人知道我在做什么错吗?
edit1:看下面的输出:
.libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/local/lib/R/library"
install.packages(c('rvest', 'jsonlite', 'data.table' ,'stringr'), repos = 'http://cran.us.r-project.org')
Warning in install.packages :
unable to access index for repository https://mran.microsoft.com/snapshot/2019-10-15/src/contrib:
cannot open URL 'https://mran.microsoft.com/snapshot/2019-10-15/src/contrib/PACKAGES'
Installing packages into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository http://cran.us.r-project.org/src/contrib:
cannot open URL 'http://cran.us.r-project.org/src/contrib/PACKAGES'
Warning in install.packages :
packages ‘rvest’, ‘jsonlite’, ‘data.table’, ‘stringr’ are not available (for R version 3.6.1)
答案 0 :(得分:0)
奇怪的是,对于完全相同的Dockerfile,我可以使用rocker / tidyverse存储库而不是rocker / rstudio安装软件包。有人知道为什么吗?