[英]unable to install R packages in Docker container
I have a task to deploy two docker containers sql server and R Studio Server with packages: rvest, odbc, rodbc, dbi. 在我的任务中,我需要同时编写 docker 和 Docker 文件,但我无法导入我安装的库。
docker-compose.yml
version: '3.9'
services:
rstudio:
build: ./docker/rstudio
container_name: etl
environment:
- PASSWORD=yourpassword
ports:
- 8787:8787
Dockerfile
FROM rocker/rstudio
RUN apt-get clean all && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
python3-pip \
&& apt-get clean all && \
apt-get purge && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN /usr/local/lib/R/bin/R -e 'install.packages("ODBC", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")' && \
/usr/local/lib/R/bin/R -e 'install.packages("RODBC", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")' && \
/usr/local/lib/R/bin/R -e 'install.packages("DBI", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")' && \
/usr/local/lib/R/bin/R -e 'install.packages("rvest", repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest")'
当我在 localhost:8787 (user:rstudio, password:yourpassword) 登录容器时,我无法导入任何库:
> library(rvest)
Error: package or namespace load failed for ‘rvest’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/xml2/libs/xml2.so':
libxml2.so.2: cannot open shared object file: No such file or directory
> library(RODBC)
Error: package or namespace load failed for ‘RODBC’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/RODBC/libs/RODBC.so':
libodbc.so.2: cannot open shared object file: No such file or directory
> library(ODBC)
Error in library(ODBC) : there is no package called ‘ODBC’
> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/local/lib/R/library"
> R.home()
[1] "/usr/local/lib/R"
我的问题:
Docker 组成执行日志:
(base) 192-168-1-105:sandpit username$ docker-compose up
Creating etl ... done
Attaching to etl
etl | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
etl | [s6-init] ensuring user provided files have correct perms...exited 0.
etl | [fix-attrs.d] applying ownership & permissions fixes...
etl | [fix-attrs.d] done.
etl | [cont-init.d] executing container initialization scripts...
etl | [cont-init.d] 01_set_env: executing...
etl | skipping /var/run/s6/container_environment/HOME
etl | skipping /var/run/s6/container_environment/PASSWORD
etl | skipping /var/run/s6/container_environment/RSTUDIO_VERSION
etl | [cont-init.d] 01_set_env: exited 0.
etl | [cont-init.d] 02_userconf: executing...
etl | [cont-init.d] 02_userconf: exited 0.
etl | [cont-init.d] done.
etl | [services.d] starting services
etl | [services.d] done.
第一条错误消息是关键:
unable to load shared object '/usr/local/lib/R/site-library/xml2/libs/xml2.so
这些 RSPM 包不安装系统依赖项(因为它们不能,它们是简单的 tar.gz 档案;该站点提供了一些帮助)。 您可以从 Ubuntu ( r-cran-{odbc,rodbc,dbi,rvest}
) 安装预制的二进制文件,或者通过例如处理系统依赖项
apt install libxml2 libodbc1
照顾 XML 和 ODBC 库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.