Installing ggpubr in Docker container rocker/r-base??
1
0
Entering edit mode
9 weeks ago

Hi everyone,

I am trying to install ggpubr and ggplot2 in the Docker container rocker/r-base from Docker Hub. Ggplot2 gets installed properly but ggpubr does not get installed. I tried to check for the package dependencies and to explicitly install them, but ggpubr is not the final image. This is my Dockerfile

# Install system dependencies
RUN apt-get update && apt-get install -y \
    libcurl4-openssl-dev \
    libssl-dev \
    libxml2-dev \
    libgit2-dev \
    libcairo2-dev \
    build-essential \
    libxt-dev \
    libgsl-dev \
    libharfbuzz-dev \
    libfribidi-dev \
    libfreetype6-dev \
    libpng-dev \
    libtiff5-dev \
    libjpeg-dev \
    libfontconfig1-dev \
    && rm -rf /var/lib/apt/lists/*

# Install R dependencies
RUN R -e "install.packages('remotes', repos='https://cloud.r-project.org/')"

# Install devtools using remotes
RUN R -e "remotes::install_cran('devtools')"

# **Create a valid R package inside the container**
RUN R -e "usethis::create_package('/usr/local/src/rplotres', open = FALSE)"

# Install ggplot2 separately
RUN R -e "install.packages('ggplot2', repos='https://cloud.r-project.org/', dependencies = TRUE)"

#Install dependencies for ggpubr

RUN R -e "install.packages(c('ggrepel', 'grid', 'ggsci', 'stats', 'utils', 'tidyr', 'purr', 'dplyr','cowplot', 'ggsignif','scales', 'gridExtra', 'glue', 'polynom', 'rlang', 'rstatix', 'tibble', 'magrittr', 'grDevices', 'knitr', 'RColorBrewer', 'gtable', 'testthat'), repos='https://cloud.r-project.org/')"

###Check Development Tools: lines to ensure everything needed is there to building packages

RUN apt-get update && apt-get install -y build-essential

# Install ggpubr separately

RUN R -e "install.packages('ggpubr', repos='https://cloud.r-project.org/', dependencies = TRUE)"

# Install the R package
RUN R -e "devtools::install('/usr/local/src/rplotres')"

# Set the command to run R by default
CMD ["R"]

I am not really sure how to proceed from here. I would really like to use ggpubr. Is there any other docker container that has ggpubr already installed? rocker/tidyverse does not either.

Any suggestions?

Thanks.

Giulia

ggpubr dockerfile docker r • 448 views
ADD COMMENT
1
Entering edit mode
9 weeks ago
ATpoint 87k

You should install non-R dependencies such as the build-essentials first, and then all the R packages in a single go. The install.packages() command solves the dependency tree so there is no advantage splitting this over so many RUNs. What is the problem? Show the errors.

I recommend generally for R the Bioconductor image which is based on Rocker with (almost) all non-R dependencies for Bioconductor packages preinstalled and container binaries are available for Bioc so many things install fast. bioconductor/bioconductor_docker:RELEASE_3_20 is the latest as of 02/2025.

In the r-base for example cmake is missing which is not covered by the build-essentials so you need to install via apt.

ADD COMMENT
0
Entering edit mode

Adding to this point, the multiple install.packages layers have not only no advantage, but a HUEGE disadvantage: Each RUN adds a layer that inflates the container size.

ADD REPLY

Login before adding your answer.

Traffic: 3124 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6