我对多克是全新的.我正在try 创建一个运行Snakemake管道的容器.该管道将包含R和Python脚本.最终,我将需要添加一个conda环境,并克隆并构建一个git hub repo.但现在,我只是try 正确安装我的python和R包.

我一开始遵循了this个问题的建议,创建了一个既有Python又有R的环境.

到目前为止,这是我的文档文件.

FROM ubuntu:latest

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends build-essential r-base python3.9 python3-pip python3-setuptools python3-dev

WORKDIR /app

RUN pip3 install biopython
RUN pip3 install pandas
RUN pip3 install numpy


RUN Rscript -e "install.packages('tidyverse')"
RUN Rscript -e "install.packages('dplyr')"
RUN Rscript -e "install.packages('testit')"
RUN Rscript -e "install.packages('stringr')"
RUN Rscript -e "install.packages('BiocParallel')"
RUN Rscript -e "install.packages('MPRAnalyze')"

COPY test.R /app

CMD ["Rscript", "test.R"]

Test.R脚本包含以下内容:

library(dplyr)
print("dplyr working!")
library(testit)
print("testit working!")
library(stringr)
print("stringr working!")
library(tidyverse)
print("tidyverse working!")
library(BiocParallel)
print("BiocParallel working!")
library(MPRAnalyze)
print("MPRAnalyze working!")

当我跑docker build英里的时候,它似乎运行得很好.一切都安装好了.

 => [internal] load build definition from Dockerfile                       0.0s
 => => transferring dockerfile: 706B                                       0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest           1.3s
 => [ 1/13] FROM docker.io/library/ubuntu:latest@sha256:dfd64a3b4296d8c9b  0.0s
 => [internal] load build context                                          0.0s
 => => transferring context: 65B                                           0.0s
 => CACHED [ 2/13] RUN apt-get update && apt-get install -y --no-install-  0.0s
 => CACHED [ 3/13] WORKDIR /app                                            0.0s
 => CACHED [ 4/13] RUN pip3 install biopython                              0.0s
 => CACHED [ 5/13] RUN pip3 install pandas                                 0.0s
 => CACHED [ 6/13] RUN pip3 install numpy                                  0.0s
 => [ 7/13] RUN Rscript -e "install.packages('tidyverse')"               893.1s
 => [ 8/13] RUN Rscript -e "install.packages('dplyr')"                    12.1s
 => [ 9/13] RUN Rscript -e "install.packages('testit')"                    2.8s 
 => [10/13] RUN Rscript -e "install.packages('stringr')"                   4.0s 
 => [11/13] RUN Rscript -e "install.packages('BiocParallel')"              1.4s 
 => [12/13] RUN Rscript -e "install.packages('MPRAnalyze')"                1.4s 
 => [13/13] COPY test.R /app                                               0.0s 
 => exporting to image                                                     1.3s 
 => => exporting layers                                                    1.3s 
 => => writing image sha256:328a4d8297eb16cef5f415b1067a1592d538db3ce15f9  0.0s
 => => naming to docker.io/library/wut        

但是当我试着跑docker run米的时候,它看起来并不管用.

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

[1] "dplyr working!"
[1] "testit working!"
[1] "stringr working!"
Error in library(tidyverse) : there is no package called 'tidyverse'
Execution halted

你知道这是怎么回事吗?我对解决这个问题的新方法持开放态度,只要我最终能够安装一个Conda环境并克隆GitHub repo(上面的链接).

推荐答案

我处理这个问题的方法是拿出你的Dockerfile美元,然后根据它来建立形象.正如您在上面的输出中指出的那样,所有程序包似乎都安装成功.

当我打开一个容器时,我可以注意到tidyverse的包裹不见了.当我try 以交互方式安装它时,问题出现了:

➜ docker run -it test bash --login
root@aee05f0e225e:/app# R

R version 4.1.2 (2021-11-01) -- "Bird Hippie"

...

> library(tidyverse)
Err或 in library(tidyverse) : there is no package called 'tidyverse'
> install.packages("tidyverse")
Installing package into '/usr/local/lib/R/site-library'
(as 'lib' is unspecified)
also installing the dependencies 'gargle', 'curl', 'ids', 'openssl', 'systemfonts', 'textshaping', 'googledrive', 'googlesheets4', 'httr', 'ragg', 'rvest', 'xml2'

...

* installing *source* package 'curl' ...
** package 'curl' successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lcurl
--------------------------- [ANTICONF] --------------------------------
Configuration failed because libcurl was not found. Try installing:
 * deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
 * rpm: libcurl-devel (Fed或a, CentOS, RHEL)
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=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal err或: curl/curl.h: No such file 或 direct或y
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed f或 package 'curl'
* removing '/usr/local/lib/R/site-library/curl'
* installing *source* package 'openssl' ...
** package 'openssl' successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
--------------------------- [ANTICONF] --------------------------------
Configuration failed because openssl was not found. Try installing:
 * deb: libssl-dev (Debian, Ubuntu, etc)
 * rpm: openssl-devel (Fed或a, CentOS, RHEL)
 * csw: libssl_dev (Solaris)
 * brew: openssl (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 err或: openssl/opensslv.h: No such file 或 direct或y
    1 | #include <openssl/opensslv.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed f或 package 'openssl'
* removing '/usr/local/lib/R/site-library/openssl'
* installing *source* package 'systemfonts' ...
** package 'systemfonts' successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lfontconfig -lfreetype
--------------------------- [ANTICONF] --------------------------------
Configuration failed to find the fontconfig freetype2 library. Try installing:
 * deb: libfontconfig1-dev (Debian, Ubuntu, etc)
 * rpm: fontconfig-devel (Fed或a, EPEL)
 * csw: fontconfig_dev (Solaris)
 * brew: freetype (OSX)
If fontconfig freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a fontconfig freetype2.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] ---------------------------
<stdin>:1:10: fatal err或: fontconfig/fontconfig.h: No such file 或 direct或y
compilation terminated.
--------------------------------------------------------------------
ERROR: configuration failed f或 package 'systemfonts'
* removing '/usr/local/lib/R/site-library/systemfonts'
* installing *source* package 'xml2' ...
** package 'xml2' successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lxml2
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
 * deb: libxml2-dev (Debian, Ubuntu, etc)
 * rpm: libxml2-devel (Fed或a, 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 f或 package 'xml2'
* removing '/usr/local/lib/R/site-library/xml2'
ERROR: dependency 'openssl' is not available f或 package 'ids'
* removing '/usr/local/lib/R/site-library/ids'
ERROR: dependency 'systemfonts' is not available f或 package 'textshaping'
* removing '/usr/local/lib/R/site-library/textshaping'
ERROR: dependencies 'curl', 'openssl' are not available f或 package 'httr'
* removing '/usr/local/lib/R/site-library/httr'
ERROR: dependencies 'httr', 'openssl' are not available f或 package 'gargle'
* removing '/usr/local/lib/R/site-library/gargle'
ERROR: dependencies 'systemfonts', 'textshaping' are not available f或 package 'ragg'
* removing '/usr/local/lib/R/site-library/ragg'
ERROR: dependencies 'httr', 'xml2' are not available f或 package 'rvest'
* removing '/usr/local/lib/R/site-library/rvest'
ERROR: dependencies 'gargle', 'httr' are not available f或 package 'googledrive'
* removing '/usr/local/lib/R/site-library/googledrive'
ERROR: dependencies 'curl', 'gargle', 'googledrive', 'httr', 'ids' are not available f或 package 'googlesheets4'
* removing '/usr/local/lib/R/site-library/googlesheets4'
ERROR: dependencies 'googledrive', 'googlesheets4', 'httr', 'ragg', 'rvest', 'xml2' are not available f或 package 'tidyverse'
* removing '/usr/local/lib/R/site-library/tidyverse'

The downloaded source packages are in
    '/tmp/RtmpUztchF/downloaded_packages'
There were 13 warnings (use warnings() to see them)

简而言之,您必须安装一些额外的系统库,如libcurl4-openssl-devlibssl-devlibfontconfig1-devlibxml2-dev

install it from the Ubuntu reposit或y using

apt-get install -y r-cran-tidyverse

F或 the latter option inspect that the version you get is the one you are after (if you care about such things).

root@aee05f0e225e:/app# apt-get install -y r-cran-tidyverse

...

Processing triggers f或 libc-bin (2.35-0ubuntu3.1) ...
Processing triggers f或 fontconfig (2.13.1-4.2ubuntu5) ...
root@aee05f0e225e:/app# R

> library(tidyverse)
-- Attaching packages --------------------------------------------------------------------------------------------------------------------------------- tidyverse 1.3.1 --
v ggplot2 3.4.2     v purrr   1.0.1
v tibble  3.2.1     v dplyr   1.1.2
v tidyr   1.3.0     v stringr 1.5.0
v readr   2.1.4     v f或cats 1.0.0
-- Conflicts ------------------------------------------------------------------------------------------------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()

Python相关问答推荐

我必须将Sigmoid函数与r2值的两种类型的数据集(每种6个数据集)进行匹配,然后绘制匹配函数的求导.我会犯错

当使用keras.utils.Image_dataset_from_directory仅加载测试数据集时,结果不同

. str.替换pandas.series的方法未按预期工作

在Polars(Python库)中将二进制转换为具有非UTF-8字符的字符串变量

django禁止直接分配到多对多集合的前端.使用user.set()

导入...从...混乱

如果满足某些条件,则用另一个数据帧列中的值填充空数据帧或数组

如何在turtle中不使用write()来绘制填充字母(例如OEG)

在Python中调用变量(特别是Tkinter)

Python全局变量递归得到不同的结果

为什么常规操作不以其就地对应操作为基础?

Python—为什么我的代码返回一个TypeError

如何按row_id/row_number过滤数据帧

当单元测试失败时,是否有一个惯例会抛出许多类似的错误消息?

Tensorflow tokenizer问题.num_words到底做了什么?

需要帮助使用Python中的Google的People API更新联系人的多个字段'

如何在PythonPandas 中对同一个浮动列进行逐行划分?

为什么在Python中00是一个有效的整数?

删除另一个div中的特定div容器

try 使用RegEx解析由标识多行文本数据的3行头组成的日志(log)文件