简体   繁体   English

无法在 r shiny docker 中安装 devtools

[英]cannot install devtools in r shiny docker

I'm trying to build a docker image for my shiny app.我正在尝试为我的 shiny 应用程序构建 docker 图像。 Below is my dockerfile .下面是我的dockerfile When I build my images, everything else seems fine, except I got error message Error in library(devtools): there is no package called 'devtools' Execution halted .当我构建图像时,其他一切似乎都很好,除了我收到错误消息Error in library(devtools): there is no package called 'devtools' Execution halted I also tried devtools::install_github('nik01010/dashboardthemes') with no success.我也试过devtools::install_github('nik01010/dashboardthemes')没有成功。 I have non clue why?我不知道为什么? What could go wrong? go 会出现什么问题? Do anyone know what is wrong with my dockerfile?有人知道我的 dockerfile 有什么问题吗? Thanks a lot.非常感谢。

# 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"]

There are a few approaches you might try.您可以尝试几种方法。

Easiest:最简单的:

Use remotes::install_github instead of devtools .使用remotes::install_github而不是devtools remotes has many fewer dependencies if you don't need the other functionality.如果您不需要其他功能,则remotes的依赖项要少得多。

Second Easiest:第二简单:

Use rocker/tidyverse image from Docker Hub instead of baseR image.使用来自 Docker Hub 的摇杆/tidyverse图像而不是 baseR 图像。

docker pull rocker/tidyverse

Change line 2:更改第 2 行:

FROM rocker/verse

Hardest:最难的:

Otherwise, you will need to figure out which dependencies you need to install inside your docker image before you can install devtools .否则,在安装devtools之前,您需要弄清楚需要在 docker 映像中安装哪些依赖项。 It will likely be obvious if you try to install it interactively.如果您尝试以交互方式安装它,这可能会很明显。

  1. Make sure the container is running确保容器正在运行
  2. Get the container name using docker ps使用docker ps获取容器名称
  3. Start a shell with docker exec -it <container name> /bin/bash使用docker exec -it <container name> /bin/bash启动 shell
  4. Start R and try to install devtools interactively启动R并尝试以交互方式安装devtools

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM