Run a Docker container - identify transdiagnostic latent factors

Reproducibility Workshop for Cognitive Science Orientation Bootcamp

Docker file

# Start with R version 4.3.2
FROM rocker/verse:4.3.2

# Install system dependencies for R packages
RUN apt-get update && apt-get install -y \
    libcurl4-openssl-dev \
    libssl-dev \
    libxml2-dev
# Set the working directory to /home/rstudio
WORKDIR  /home/rstudio

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

COPY renv.lock renv.lock
COPY renv renv
COPY renv.lock renv.lock
#COPY TSciM_workshop_code.R TSciM_workshop_code.R
#COPY GillanEtAl_eLife.rds GillanEtAl_eLife.rds

# Change ownership of the directory to the 'rstudio' user and activate 'renv'
RUN chown -R rstudio . \
 && sudo -u rstudio R -e 'source("renv/activate.R");  renv::restore()'

Instructions

These are the steps I used to build the docker image.

  1. Build the Docker image:
  2. docker build . -t nghuixin/tscim_club_feb2024
  3. Push the Docker image:
  4. docker push nghuixin/tscim_club_feb2024

To run the docker image, begin with this step:

  1. Pull the Docker image:
  2. docker pull nghuixin/tscim_club_feb2024:1.0
  3. Run the Docker container (no mounted volumes):
  4. docker run --rm -p 8787:8787 -e DISABLE_AUTH=true nghuixin/tscim_club_feb2024:1.0
  5. Run the Docker container with mounted volumes:
  6. docker run -it -e DISABLE_AUTH=true -p 8787:8787 -v ${pwd}/TSciM_workshop_code.R:/home/rstudio/TSciM_workshop_code.R -v ${pwd}/GillanEtAl_eLife.rds:/home/rstudio/GillanEtAl_eLife.rds nghuixin/tscim_club_feb2024:1.0

Relevant Links