Dockerizing在R中使用mxnet软件包的应用程序

我正在使用“mxnet”软件包dockerizing一个shiny的应用程序。 经过大量的努力,我得出结论,我需要构build和安装包,而不是通常从dmlc仓库安装它。 下面是我简化的dockerfile,试图构build和安装mxnet:

FROM r-base:latest RUN apt-get update && apt-get install -y \ sudo \ gdebi-core \ pandoc \ pandoc-citeproc \ libcurl4-gnutls-dev \ libcairo2-dev/unstable \ libxt-dev \ libssl-dev # Download and install shiny server RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os- build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \ VERSION=$(cat version.txt) && \ wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os- build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \ gdebi -n ss-latest.deb && \ rm -f version.txt ss-latest.deb # Here comes the installation of other required packages: # ....... #*** Here comes the problamatic bit: building Installing mxnet RUN sudo apt-get update RUN sudo apt-get install -y build-essential git libatlas-base-dev libopencv-dev RUN git clone --recursive https://github.com/dmlc/mxnet RUN cd mxnet; make -j$(nproc) RUN Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')" RUN cd R-package RUN Rscript -e "library('devtools'); library('methods'); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)" RUN cd .. RUN make rpkg COPY shiny-server.conf /etc/shiny-server/shiny-server.conf COPY /myapp/* /srv/shiny-server/ EXPOSE 80 COPY shiny-server.sh /usr/bin/shiny-server.sh CMD ["/usr/bin/shiny-server.sh"] 

运行后,我收到一个错误说:

 can not cd to R-Package 

任何帮助?

尝试

RUN cd mxnet; make -j$(nproc)\ && Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')"

你的RUN cd ..不会做你所期望的,就像打开一个terminal,做cd abc/def ,在另一个terminal里,在/ home / $ USER,做cd .. ,你不会在ABC。

您应该对RUN命令进行分组,以限制图像中的图层数量,请参阅

https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/

检查Dockerfile中的WORKDIR指令

https://docs.docker.com/engine/reference/builder/#workdir

你可以通过启动一个shell来检查是否正确完成(或不是)

docker run -it your_image /bin/bash

然后检查是否存在。