Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Dockerfile for minimum image size on R-base

$
0
0

I'm trying to minimize the size of my docker image. It's on R-Base from the rocker project. It needs to be as small as possible, since it is used as a container instance in a cloud based workflow.

The image needs some extra packages (dplyr, pdftools, stringr and AzureStor). Some are available as binary, but AzureStor I could not find as such.

I already used some recommended commands to minimize size. What can I do more? Please read the docker file below. A few options I'm considering now:

  • Can I save space using 'no cache'? How do I 'implement' this?
  • Is there a binary version for a R package like AzureStor? I can't find it.
  • Are there any other build commands or dockerfile lines I can use to reduce any excess size?

Any help would be much appreciated!

Here is my current dockerfile

    FROM rocker/r-base:latest
## install binary, build and dependend packages from single run command

RUN apt-get update && apt-get install -y -qq --no-install-recommends --purge
r-cran-pdftools \
r-cran-dplyr \
r-cran-stringr \
libxml2-dev \
libssl-dev && \

## install non-binary packages (from the same run command)

echo "r <- getOption('repos');r['CRAN'] <- 'http://cran.us.r-project.org'; options(repos = r);"> ~/.Rprofile && \
Rscript -e "install.packages(c('AzureStor'))"&& \

mkdir -p /scripts \

## remove and clean what we can (still the same run command)
apt-get autoclean && \
apt-get -y autoremove libssl-dev && \
rm -rf /var/lib/apt/lists/*

## copy code
COPY script / script

## Set workdir
WORKDIR /scripts

## command line for autorunning the entire rscript
CMD [ "Rscript", "runscript.R"]

Right now, the size is around 800 mb. Hoping to get this down.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>