Bioconductor / bioconductor_docker

Docker Containers for Bioconductor - NEW!
https://bioconductor.org/help/docker/
Artistic License 2.0
71 stars 30 forks source link

Lighter bioconductor container in the future? #97

Closed JihedC closed 2 months ago

JihedC commented 2 months ago

Thank you for creating containers with bioconductor, I use it quite often to build my own containers with packages such as plyranges or rtracklayer.

The container image is now: 1.36 GB here

At the moment, it sometime causes problem when I use the container via apptainer on a partition that has a limited memory size (issue with the cache of the container).

I was wondering if there is a plan to reduce the base image size in order to allow for lighter containers in the future?

Or are there may be already some tips to reduce the size of the container after built?

Thanks in advance!

Jihed

almahmoud commented 2 months ago

Hello, As far as I know, the image has had a relatively stable size (~1.4 Gb) for a few years. We reduced it slightly (~10%) about a year ago when we squashed layers in our building process.

As a generic way of possibly reducing size (or at least squashing additional layers), you may try a multi-stage build similar to what we do. Quick example:

FROM bioconductor/bioconductor:3.18 AS build
RUN Rscript -e '........'
RUN apt install ......
RUN bash cleanup.sh

FROM bioconductor/bioconductor:3.18 AS final
COPY --from=build / /

Your image could then be pushed with just the final layer on top of the bioconductor image, and discard any intermediate layers. See more at https://docs.docker.com/build/building/multi-stage/

More generally, if you're using the image for R directly and don't need RStudio, you may switch to using bioconductor/r-ver which is built on a slightly smaller image from Rocker, so the final image tends to be ~1.1Gb vs ~1.4Gb. Not a big difference, but hopefully somewhat helpful if you didn't already know about it.

Feel free to close the issue if this is what you were looking for and/or follow-up with more questions

JihedC commented 2 months ago

Thanks for the reply! That's the information I was looking for!