Containerization with Docker

https://hutchdatascience.org/Containers_for_Scientists/02-why-containers.html

https://console.cloud.google.com/artifacts/docker/broad-dsp-gcr-public/us/us.gcr.io/anvil-rstudio-bioconductor

Motivation:

I want to create my own custom docker built off the base image for RStudio for Terra.

I want this custom image to allow for GitHub Copilot to be enabled.

These steps assume that you have 1) already created a Docker account and 2) installed Docker on your local laptop

Step 1

# pull image to your local computer

docker pull \
    us.gcr.io/broad-dsp-gcr-public/anvil-rstudio-bioconductor:3.21.0

Step 2

Go to directory where want to keep Dockerfile

Create Dockerfile and save as Dockerfile

cat > Dockerfile << EOF
# STEP 1: Use the downloaded Terra RStudio Base Image
FROM us.gcr.io/broad-dsp-gcr-public/anvil-rstudio-bioconductor:3.21.0
LABEL maintainer="Your Name <[email protected]>"
WORKDIR /home/rstudio/tb4i_analysis
# STEP 2: Install Node.js (Essential Copilot Dependency)
RUN apt-get update -qq \
    && apt-get install -y --no-install-recommends nodejs \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*
# STEP 3: Configure RStudio Server to Enable GitHub Copilot
RUN echo "copilot-enabled=1" >> /etc/rstudio/rsession.conf
EOF

Step 3

# build docker image
# note: i have to specify --platform because my laptop has Apple Silocon Chip but need linux/amd64 because that is what Terra base image uses

docker build --platform linux/amd64 -t username/dockerimagename .

Step 4

Use the image name and tag as a custom image in Terra.bio.

if you don’t want to build this custom image yourself, you can use my image:

https://hub.docker.com/r/mattkrantz/anvil-rstudio-bioconductor-tb4i/tags

mattkrantz/anvil-rstudio-bioconductor-tb4i:3.21.0

Note

Containers achieve this by reusing large parts of the host operating system.

Important

Software versions should be precisely documented to ensure full computational reproducibility.

Rocker Project