These Docker files are used to build computational environments to teach students or train employees. For instance, these are used in:
Docker images are automatically tested and built on Docker Hub.
All Docker images ready to use are available at the Dockerhub docker-for-teaching repository.
Docker containers can be run. For domain-specific instructions, see the instructions below.
To test it locally, you'll need to install Docker Desktop first: see instructions at docker desktop.
Based on the DockerHub rocker/tidyverse image but with three added libraries (skimr, plotly and nycflights13).
docker run --detach --name rstudio_instance -e PASSWORD=mypwd -p 8787:8787 mgalland/docker-for-teaching:openr-latest
Then navigate to http://localhost:8787 in your web browser. You should have an RStudio session running. Type rstudio as the user name and your password.
Explanations:
The --detach flag makes sure the container runs in the backgroupd and returns the interactive command-line prompt.
The --name gives a name to the running container for easy retrieval.
The -p 8787:8787 follow the format -p host_port:container_port. Therefore the port 8787 inside the container will be exposed to the outside port on the host machine. That way, the running instance of RStudio can be access through the :port format.
The phylogeny/ folder contains the Docker file used to build the image.
The Docker image contains:
To use it locally on your machine:
docker run --rm -it -v $PWD:/home/ mgalland/docker-for-teaching:phylogeny-latestExplanations:
The --detach flag makes sure the container runs in the backgroupd and returns the interactive command-line prompt.
The --it starts an interactive session (so you enter the shell directly).
The -v mounts your current working directory onto the /home/ folder inside your container. That way, you can access the files in your working directory from within the container.
A Dockerfile to follow the Carpentry-style microbiota data analysis lesson.
This Docker image contains:
data_loue_16S_nonnorm_grp.txt, data_loue_16S_nonnorm_taxo.txt and data_loue_16S_nonnorm.txt.vegan version 2.5-6tidyverse version 1.3.0pheatmap version 1.0.12ade4 version 1.7-10multcomp version 1.4-10patchwork version 1.0.0agricolae version 1.3-0FSA version 0.8.27rcompanion version 2.3.0phyloseq Bioconductor version 3.10dada2 Bioconductor version 3.10To use it locally on your machine:
To use it locally on your machine:
docker run --detach --name rstudio -e PASSWORD=<choose a password> -p 8787:8787 mgalland/docker-for-teaching:microbiome-latest.rstudio as the user name and your select password.A Dockerfile to perform the command-line parts of the Carpentry-style RNA-seq lesson: the "fastq NGS quality check" and the "fastq to counts" section.
In addition, it can also be used to teach the Carpentry Shell lesson.
The Docker image contains:
data-shell/ dataset from the Shell novice lesson.To use it locally on your machine:
docker run -it mgalland/docker-for-teaching:fastq-2021.2 vCPUs and 2GB of RAM are sufficient per machine to run the lesson.
A Dockerfile for the Carpentry-style RNA-seq lesson.
The image is based on a Docker Bioconductor image release 3.10.
The Docker image contains:
From CRAN:
devtools (from the MRAN microsoft CRAN mirror of 2020/01/01.pheatmap version 1.0.12tidyverse version 1.3.0pwr version 1.2.0RColorBrewer version 1.0.5BiocManager version 1.30.1biomartr version 0.9.0From Bioconductor release 3.10:
EnhancedVolcanoDESeq2clusterProfilerbiomaRtorg.At.tair.dbBiostringsvsnTwo datasets are included.
counts.tsvexperimental_design_modified.tsv
This dataset is included in the Docker image itself.To use it locally on your machine:
docker run --detach --name machine01 -e PASSWORD=<choose a password> -p 8787:8787 mgalland/docker-for-teaching:rnaseq-2021.rstudio as the user name and your select password.Explanations:
The --detach flag makes sure the container is still running in the background after the prompt returns.
The base image is built on a RStudio server that will ask you for two things: a user name that is always rstudio and a password which is one you have to create. You will be asked for a user name and a password.
A Dockerfile for the Carpentries incubator lesson on shotgun metagenomics.
The image is based on a Docker Bioconductor image release 3.10.
For now, I have relied on the Digital Ocean cloud computing platform to deploy Docker containers that in turn serve RStudio instances.
If you only want to run one RStudio virtual machine, then follow these steps:
ssh to your machine e.g. ssh root@ip and enter the Digital Ocean provided password. The IP address will be indicated in your "Droplets" sidebar. For example, use ssh [email protected] if your IP address is 134.209.84.69.screen to make sure that your VM stays up and running when you log out / turn off your computer. See this help forum.docker run --rm --name rstudio -e PASSWORD=mypwd -p 8787:8787 mgalland/docker-for-teaching:openr-latest. (choose the appropriate Docker image). You can define your own username and password.If you want to run multiple containers (e.g. one per student), you need to perform the same steps as for a single machine (see above). The difference is that expose a different port on the host each time.
Here's an example for two students:
docker run --detach --name machine-01 -v ~/machines/machine01/:/home/rstudio/ -e PASSWORD=student01 -p 8080:8787 mgalland/docker-for-teaching:openr-latestdocker run --detach --name machine-02 -v ~/machines/machine02/:/home/rstudio/ -e PASSWORD=student02 -p 8081:8787 mgalland/docker-for-teaching:openr-latestNotice that student 1 uses port 8080 while student 2 uses port 8081.
... etc ...
A small Python script called create_docker_commands_for_students.py is available and can be used on a file called students.tsv with tabulated-separated values with the following format:
| student | machine | password | port |
|---|---|---|---|
| John Doe | machine-01 | john | 8787 |
| Jane Doe | machine-02 | jane | 8788 |
In a Python virtual environment with pandas available, run the following command:
python create_docker_commands_for_students.py students.tsv
This will create the Docker commands that can be copy-pasted in the shell of the cloud instance:
docker run --detach --name machine-01 -e PASSWORD=john -p 8787:8787 mgalland/docker-for-teaching:openr-latest
docker run --detach --name machine-02 -e PASSWORD=jane -p 8787:8788 mgalland/docker-for-teaching:openr-latest
In this way, you can have one machine per student, each one on its own port with its own password.
See this blog post: https://medium.com/@mccode/understanding-how-uid-and-gid-work-in-docker-containers-c37a01d01cf
docker stop $(docker ps -a -q)docker start <container_id or container_name>docker rm $(docker ps -a -q)docker rm $(docker ps -a -q)docker rmi $(docker images -q) --forceDroplets are Linux-based Virtual Machines that can be created and deleted on demand.
Digital Ocean has a docl command-line interface that can be used to perform actions programmatically.
This is useful when multiple droplets need to be created or modified for instance.
Link to the doctl documantion
To use doctl you will need to create an access token (DO > API).
Assign a bash environmental variable (that stays on your computer) to keep it secret when recording commands.
echo "export DO_TOKEN=you_secret_token" >> ~/.bash_profile # to create an env variable called $DO_TOKEN
source ~/.bash_profile # to activate your profile
This creates the $DO_TOKEN environmental variable that you can use to authenticate with the doctl command-line.
It is often useful to list the available droplets, their CPUs, etc. in order to create multiple ones with the same configuration for instance.
To list all available droplets, type:
doctl compute size list
Slug Memory VCPUs Disk Price Monthly Price Hourly
s-1vcpu-1gb 1024 1 25 5.00 0.007440
s-1vcpu-1gb-amd 1024 1 25 6.00 0.008930
s-1vcpu-1gb-intel 1024 1 25 6.00 0.008930
s-1vcpu-2gb 2048 1 50 10.00 0.014880
s-1vcpu-2gb-amd 2048 1 50 12.00 0.017860
s-1vcpu-2gb-intel 2048 1 50 12.00 0.017860
s-2vcpu-2gb 2048 2 60 15.00 0.022320
s-2vcpu-2gb-amd 2048 2 60 18.00 0.026790
s-2vcpu-2gb-intel 2048 2 60 18.00 0.026790
You can use a regular grep to filter this list. For instance, to get the memory-optimized droplets that start with an "m", grep them with:
doctl compute size list |grep "^m-"
The "slug" column contains the short description of the machine configuration. You will have to specify it when creating the machines.
To get a list of your running droplets, type:
doctl compute droplet list --format "ID,Name,PublicIPv4"
For instance, to create a Virtual Machine (droplet) with Docker 19.03.12 running on Ubuntu 20.04, do:
doctl compute droplet create --image docker-20-04 \ # Ubuntu 20.04 with Docker installed
--enable-monitoring \ # Adds monitoring for CPU usage, RAM etc.
--region ams3 \ # region where the droplet is created (e.g. Amsterdam 3)
--tag-name rnaseq \ # tag for droplet management
--ssh-keys 27380279 \ # A list of SSH key fingerprints to embed upon creation
--size s-2vcpu-2gb \ # slug format to indicate compute size and resources
[my_droplet_name]
Important notes
--tag-name is useful to perform actions on multiple droplets at once.--ssh-keys will point to a SSH key ID to be used with the Droplet root account. This avoids the need for passwords. Here I give my custom public key ID 27380279. If this flag is not provided, you will get an email with the login credentials.It is then rather easy to create a series of VMs called "machine-01", "machine-02" using a for loop.
Say you want to create 20 machines, then:
for i in {1..20}
do
echo "machine-${i}"
doctl compute droplet create --image docker-20-04 \ # Ubuntu 20.04 with Docker installed
--enable-monitoring \ # Adds monitoring for CPU usage, RAM etc.
--region ams3 \ # region where the droplet is created (e.g. Amsterdam 3)
--tag-name rnaseq \ # tag for droplet management
--ssh-keys 27380279 \ #
--size s-2vcpu-2gb \ # slug format to indicate compute size and resources
"machine-${i}" # creates a name with the machine number
done
Using the tag that was specified with --tag-name it is possible to delete all machines at once:
doctl compute droplet delete --tag-name rnaseq
For the phylogeny course and the RNA-seq courses.
For the microbiome and RNA-seq courses.
Content type
Image
Digest
Size
2.5 GB
Last updated
over 4 years ago
docker pull mgalland/docker-for-teaching:rnaseq-latest