Docker - bcb420-2023/Angela_Uzelac GitHub Wiki

Introduction

Container

  • An instance of an image.
  • the self-contained running system.
  • There can be multiple containers derived from the same image.

Image

  • contains the blueprint of a container.
  • In docker, the image is built from a Dockerfile

Docker Volumes

  • Anything written on a container will be erased when the container is erased ( or crashes) but anything written on a filesystem that is separate from the container will persist even after a container is turned off.
  • A volume is a way to associate data with a container that will persist even after the container maps a drive on the host system to a drive on the container.
  • In the docker run command that creates our container, the statement: -v ${PWD}:/home/rstudio/projects maps the directory ${PWD} to the directory /home/rstudio/projects on the container. Anything saved in /home/rstudio/projects will actually be saved in ${PWD}
  • To create a container: docker run -e PASSWORD=changeit --rm \ -v /Users/risserlin/bcb420_code:/home/rstudio/projects \ -p 8787:8787 \ risserlin/bcb420-base-image:winter2022

Setup

Install Docker

  1. Download and install docker desktop.
  2. Need additional updates: i. update linux kernel ii. in command prompt: wsl --install
  3. for additional updates: https://docs.microsoft.com/en-us/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package
  4. Make sure to restart system after updates
  5. launch docker desktop app.
  6. Open windows Power shell
  7. navigate to directory: C:\Users\angel\BCB420
  8. Run the following command: docker run -e PASSWORD=bcb420 --rm -v ${PWD}:/home/rstudio/projects -p 8787:8787 risserlin/bcb420-base-image:winter2022
  9. Note: type it in manually instead of copy and pasting - it didn't work when copy and pasting

On docker desktop now see all containers and can manage them.

Open RStudio by typing localhost:8787 in browser, type in username rstudio, password bcb420, open projects folder and make a new script. MA!

Homework

  1. Run the Docker image
  2. open localhost:8787
  3. make script - called first_script
  4. to install packages DESeq2 and pheatmap run: `if (!require("BiocManager", quietly = TRUE)){ install.packages("BiocManager") }

BiocManager::install("DESeq2")

if (!require("pheatmap", quietly = TRUE)){ install.packages("pheatmap") } ` 5. created script called compFoldChange