主要在Ubuntu 18.04和CentOS 7下进行测试。
直接使用rocker提供的r镜像。
docker pull r-ubuntu:18.04
https://github.com/rocker-org/rocker/tree/master/r-ubuntu[1]
启动和进入镜像:
docker run --name ubuntu -it rocker/r-ubuntu:18.04 /bin/bash
进入R,然后安装CRAN包的安装方式进行安装。
一些包安装失败:
Warning messages:
1: In install.packages("UCSCXenaShiny") :
installation of package ‘curl’ had non-zero exit status
2: In install.packages("UCSCXenaShiny") :
installation of package ‘openssl’ had non-zero exit status
3: In install.packages("UCSCXenaShiny") :
installation of package ‘httr’ had non-zero exit status
4: In install.packages("UCSCXenaShiny") :
installation of package ‘UCSCXenaTools’ had non-zero exit status
5: In install.packages("UCSCXenaShiny") :
installation of package ‘rio’ had non-zero exit status
6: In install.packages("UCSCXenaShiny") :
installation of package ‘car’ had non-zero exit status
7: In install.packages("UCSCXenaShiny") :
installation of package ‘rstatix’ had non-zero exit status
8: In install.packages("UCSCXenaShiny") :
installation of package ‘ggpubr’ had non-zero exit status
9: In install.packages("UCSCXenaShiny") :
installation of package ‘UCSCXenaShiny’ had non-zero exit status
逐一测试下问题。
安装curl包问题:
------------------------- 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=...'
--------------------------------------------------------------------
安装curl的依赖:
apt update
apt install libcurl4-openssl-dev
安装openssl包问题:
--------------------------- [ANTICONF] --------------------------------
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.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=...'
-------------------------- [ERROR MESSAGE] ---------------------------
tools/version.c:1:10: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
--------------------------------------------------------------------
安装依赖:
apt install libssl-dev
安装UCSCXenaShiny成功后,进一步关注App启动时的依赖安装。
xml2包安装失败:
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
* deb: libxml2-dev (Debian, Ubuntu, etc)
* rpm: libxml2-devel (Fedora, CentOS, RHEL)
* csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.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=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘xml2’
apt install libxml2-dev
ERROR: dependencies ‘gmp’, ‘Rmpfr’ are not available for package ‘PMCMRplus’
apt install libgmp3-dev
apt install libmpfr-dev
错误there is no package called ‘shinythemes’
install.packages("shinythemes")
参考 https://github.com/jlisic/R-docker-centos/blob/master/centos-7-epel/Dockerfile[2] 处的Dockerfile文件先配置CentOS下的R环境。
docker pull centos:centos7
docker run -it --name centos7 centos:centos7
# set up EPEL
yum -y install epel-release
yum -y update
# set locales
echo "LANG=en_US.utf8" >> /etc/locale.conf
localedef -c -f UTF-8 -i en_US en_US.UTF-8
export LC_ALL=en_US.UTF-8
# install R
yum -y install R-core R-core-devel R-java R-cpp openssl-devel libcurl-devel \
&& echo 'options(repos = c(CRAN = "https://cran.rstudio.com/"), download.file.method = "libcurl")' >> /usr/lib64/R/etc/Rprofile.site
类似Ubuntu,直接用CRAN方式安装。
根据上面 Ubuntu 的经验将一些依赖库装好。
yum update && yum install -y libcurl-devel openssl-devel libxml2-devel
安装 nloptr 报错。原因是最新版本仅支持 R≥4.0(测试使用的3.6)。
libtool: link: ERROR: no information for variable 'AR' cru
参考 https://stackoverflow.com/questions/62900525/install-lme4-from-cran-on-ubuntu[3] 安装较低版本解决:
packageurl <- "https://cran.r-project.org/src/contrib/Archive/nloptr/nloptr_1.2.1.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
启动时报错 package ‘pacman’ is not available (for R version 3.6.0)
:
install.packages("pacman")
ERROR: dependencies ‘gmp’, ‘Rmpfr’ are not available for package ‘PMCMRplus’
yum install install gmp-devel
yum install mpfr-devel
安装 jpeg 报错。
yum install libjpeg-devel
grid-renderer.h:61:94: error: no matching function for call to ‘Rcpp::Vector<10, Rcpp::PreserveStorage>::Vector(int, bool&, const GraphicsContext&)’
yum install cairo-devel
还是不行,参考 https://stackoverflow.com/questions/63962253/problem-compiling-the-´gridtext´-package-in-r[4] 调整 C++ 版本。
yum install centos-release-scl
yum install devtoolset-9
# If you use your non-root account to install packages,
# change /root to /home/your_id in the following command
mkdir -p /root/.R
vi /root/.R/Makevars
在文件中加入内容:
CXX11=/opt/rh/devtoolset-9/root/usr/bin/g++ -std=c++11
有意思的是我发现在安装后对容器大小进行查看,发现centos7差不多是ubuntu的2倍。
[root@VM-0-5-centos ~]# docker container ls -sa
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
5197b616d026 centos:centos7 "/bin/bash" 3 hours ago Exited (0) About a minute ago centos7 2.27GB (virtual 2.47GB)
be2edf9620e7 rocker/r-ubuntu:18.04 "/bin/bash" 4 hours ago Exited (0) 55 seconds ago ubuntu 651MB (virtual 1.26GB)
[1]
https://github.com/rocker-org/rocker/tree/master/r-ubuntu: https://github.com/rocker-org/rocker/tree/master/r-ubuntu
[2]
https://github.com/jlisic/R-docker-centos/blob/master/centos-7-epel/Dockerfile: https://github.com/jlisic/R-docker-centos/blob/master/centos-7-epel/Dockerfile
[3]
https://stackoverflow.com/questions/62900525/install-lme4-from-cran-on-ubuntu: https://stackoverflow.com/questions/62900525/install-lme4-from-cran-on-ubuntu
[4]
https://stackoverflow.com/questions/63962253/problem-compiling-the-´gridtext´-package-in-r: https://stackoverflow.com/questions/63962253/problem-compiling-the-´gridtext´-package-in-r