Journal 1.2: Docker - bcb420-2025/Keren_Zhang GitHub Wiki

Table of Contents

Time

Date: Jan 7th - Jan 10th, 2025

Estimated Time: 1h

Actual Time: 2h

Installation

The latest version of Docker is downloaded from https://www.docker.com/products/docker-desktop/ on Jan 7th

  • I have an AMD64 Windows computer
  • Docker Version: Docker Desktop 4.37.1
  • Logged in using GitHub account

Image Creation

Folder Setup

Windows Subsystem for Linux is used in the Virtual Studio Code IDE.

Local Folder Location: /mnt/c/Users/Keren/BCB420-2025/BCB420

Created Docker file as Dockerfile

Commands Used:

PS C:\Users\Keren\BCB420-2025> wsl
(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025$ mkdir BCB420
(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025$ cd BCB420/
(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ git init
(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ git pull [email protected]:bcb420-2025/Keren_Zhang.git

Pulling

To Pull the base Docker image:

 docker pull risserlin/bcb420-base-image:winter2025 

To check that the image is successfully pulled:

 docker images

Example Output:

(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ docker pull risserlin/bcb420-base-image:winter2025
winter2025: Pulling from risserlin/bcb420-base-image
7646c8da3324: Pulling fs layer                                                                                                                                                                                                                                                                                                                                                             
a2977a275248: Waiting                                                                                                                                                                                          
aae3293b611a: Pull complete
...
43a8ac060eec: Pull complete
31ed7f2693d1: Pull complete
Digest: sha256:cb5f184853b527301cf8313ca26bdfe9d5e0d7a31c2c77d1ff936595a0972aca
Status: Downloaded newer image for risserlin/bcb420-base-image:winter2025
docker.io/risserlin/bcb420-base-image:winter2025

(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ docker images
REPOSITORY                    TAG                IMAGE ID       CREATED       SIZE
risserlin/bcb420-base-image   winter2025         c8fdefabc4d7   11 days ago   5.49GB

New Image

1. Existing Image as Base

To create a new Docker image based on the existing risserlin/bcb420-base-image:winter2025 image, a Dockerfile is used to define the new image's configuration.

(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ touch Dockerfile

Using the correct image name and image tag:

FROM risserlin/bcb420-base-image:winter2025

2. Add Additional Libraries

To add additional R libraries such as DESeq2, pheatmap, and enrichplot to the Docker image:

RUN R -e "install.packages(c('BiocManager'), repos='http://cran.us.r-project.org')" && \
    R -e "BiocManager::install(c('DESeq2', 'pheatmap', 'enrichplot'))"

3. Create Container

Before the container could be create, the new image has to be built from the Dockerfile:

docker build -t bcb420:version-1 .

(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ docker images
REPOSITORY                    TAG                IMAGE ID       CREATED         SIZE
bcb420                        version-1          9347b5fae332   6 seconds ago   5.49GB

A custom tag should be following the -t in the format repository_name:tage_name and the . suggests that the Dockerfile should be looked for in the current directory. Tag should be in lowercase.

Issue Encountered: One problem that I had was that the images takes a very very long time to build. To fix issues, the Dockerfile is changed so that BioManager is only installed when necessary.

Next, the image is ran using the following command:

docker run -e PASSWORD=changeit \ -v "$(pwd)":/home/rstudio/projects \ -p 8787:8787 \ bcb420:version-1

Example Output:

(base) kk@LAPTOP-0MVV563P:/mnt/c/Users/Keren/BCB420-2025/BCB420$ docker run -e PASSWORD=changeit \
  -v "$(pwd)":/home/rstudio/projects \
  -p 8787:8787 \
  bcb420:version-1
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01_set_env: executing...
skipping /var/run/s6/container_environment/HOME
skipping /var/run/s6/container_environment/PASSWORD
skipping /var/run/s6/container_environment/RSTUDIO_VERSION
[cont-init.d] 01_set_env: exited 0.
[cont-init.d] 02_userconf: executing... 
[cont-init.d] 02_userconf: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.

To access the Rstudio instance on port 8787:

  • Open up a Browser, like Google Chrome
  • Go to: http&#58&#59;//localhost&#58&#59;8787/
  • Username: rstudio
  • Password (as specified in command): changeit

4. Basic RNotebook

Task Use your image to create a basic RNotebook that does the following-

  • create a 5 by 10 matrix of random integers
  • define column names as cond1, cond2, cond3, cond4, cond5, ctrl1, ctrl2, ctrl3, ctrl4, ctrl5
  • define row names as gene1, gene2, gene3 ...
  • Compute the fold change for each gene.
⚠️ **GitHub.com Fallback** ⚠️