Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
How to build a Docker image with the right R and package versions and open Rstudio with them afterwards?

I just finished writing a manuscript for publication in a scientific journal. I want my research to be reproducible, so besides sharing my original and compiled R markdown notebooks on Github, I would like to save the environment in which I was analysing my data (including the data, notebooks and specific R and package versions) in a Docker container. Moreover, I would like anyone trying to reproduce my work to be able to execute this code in an interactive Rstudio session.

I was able to create a Dockerfile with the correct environment. Here is a toy example:

FROM rocker/r-ver:3.5.1

RUN mkdir /home/working_directory
RUN mkdir /home/working_directory/bin

RUN R -e 'options(repos = \
  list(CRAN = "http://mran.revolutionanalytics.com/snapshot/2019-01-01")); \
  install.packages("ggplot2")'

COPY current/0[1-8]-*.Rmd /home/working_directory/
COPY current/bin/utils.R /home/working_directory/bin/

RUN R

However, this doesn't allow the users to read the Rmd notebooks and execute the code line by line. A workaround is to run the image rocker/rstudio, and install the packages from there, but I would like to be able to do so from a single docker build call. Unfortunately, I wasn't able to do so.

Cheers!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The Rocker RStudio image should have what you need - RStudio on top R. If you want specifically R 3.5.1, you can find the source here:

  • https://github.com/rocker-org/rocker-versioned/blob/master/rstudio/3.5.1/Dockerfile

For more details on how to use it read https://hub.docker.com/r/rocker/rstudio.

To just use the pre-built images with a specific R version

# with R version 3.5.1:
docker pull rocker/rstudio:3.5.1

To investigate the image interactively:

docker run --rm -it rocker/rstudio:3.5.1 bash

Now we can run for example:

# Check R version
Rscript -e "sessionInfo()[['R.version']][['version.string']]"
# [1] "R version 3.5.1 (2018-07-02)"

# Check RStudio Server version
rstudio-server version
# 1.1.463

# Exit when done
exit
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda