首页 > 解决方案 > 无法在 r shiny docker 中安装 devtools

问题描述

我正在尝试为我闪亮的应用程序构建一个 docker 映像。下面是我的dockerfile。当我构建图像时,其他一切似乎都很好,除了我收到错误消息Error in library(devtools) : there is no package called ‘devtools’ Execution halted。我也试过devtools::install_github('nik01010/dashboardthemes')没有成功。我不知道为什么?会出什么问题?有人知道我的 dockerfile 有什么问题吗?非常感谢。

# Install R version 3.6
FROM r-base:3.6.0

# Install Ubuntu packages
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 ShinyServer (latest version)
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

# Install R packages that are required
RUN R -e "install.packages(c('devtools', 'shiny','shinythemes','shinydashboard','shinyWidgets','shinyjs', 'tidyverse', 'dplyr', 'ggplot2','rlang','DT','lubridate', 'plotly',  'leaflet', 'mapview', 'tigris', 'rgdal', 'visNetwork', 'wordcloud2', 'arules'), repos='http://cran.rstudio.com/')"
RUN R -e "library(devtools)"
RUN R -e "install_github('nik01010/dashboardthemes')"


# Copy configuration files into the Docker image
COPY shiny-server.conf  /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/

# Make the ShinyApp available at port 80
EXPOSE 80

# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh

CMD ["/usr/bin/shiny-server.sh"]

标签: rdockershiny

解决方案


您可以尝试几种方法。

最简单的:

使用remotes::install_github而不是devtools. remotes如果您不需要其他功能,则依赖项会少得多。

第二简单:

使用来自 Docker Hub 的rocker/tidyverse映像而不是 baseR 映像。

docker pull rocker/tidyverse

更改第 2 行:

FROM rocker/verse

最难的:

否则,在安装devtools. 如果您尝试以交互方式安装它,这可能会很明显。

  1. 确保容器正在运行
  2. 使用获取容器名称docker ps
  3. 启动一个shelldocker exec -it <container name> /bin/bash
  4. 开始R并尝试以devtools交互方式安装

推荐阅读