-
Notifications
You must be signed in to change notification settings - Fork 0
Docker
Generate a Docker image with R and Rstudio installed.
Alan Murphy created a Docker container that has RStudio, Bioconductor and the R package scFlow installed. Additionally, this container is optimised to enable much master installation of R packages (~8x faster than default).
Note that the OS within this Docker container is Linux (even if you are running it on a Mac).
-
Install Docker Desktop
-
Within Docker Desktop, click the Settings (gear icon) in the upper right, and go to Resources -> Advanced. Raise all the limits to the max (or whatever you like). This prevents Docker from underutilising your computer’s resources.
-
Within Docker Desktop, make sure you’re not running any other docker containers that are taking up resources unnecessarily (under the Containers/Apps section).
-
In command line, create a Docker image using from Alan Murphy's Dockerhub, called scfdev. Make sure to modify the paths that you want to mount to the docker image using the
-v
flags (syntax: <local_path>:<path_within_container>). This is important to do at this step, because Docker does not have access to any folder/files that you do not explicitly give it access it, and this cannot be changed after creating the Docker image.
docker run \
-e PASSWORD=scflow \
-p 8787:8787 \
-v ~/Desktop:/Desktop -v /Volumes:/Volumes \
almurphy/scfdev
-
Access the image via a web browser using the URL: http://localhost:8787/
-
Log into RStudio within the browser (username: rstudio, password: scflow). You can now modify the docker image (e.g. installing new packages) and these changes will be saved even after exiting.
Bioconductor also distributes a similar Docker container (albeit without scFlow and not optimised for fast R package installation).
docker run \
-e PASSWORD=bioc \
-p 8787:8787 \
-v ~/Desktop:/Desktop -v /Volumes:/Volumes \
bioconductor/bioconductor_docker:devel
Note that the RStudio password here has been set to bioc .
You may notice that you can't edit root files within the Docker. This is problematic when trying to install packages like MAGMA.
You can resolve this by using the docker cp command (replace my_container with the name of your Docker container):
docker cp ~/Downloads/magma_v1.09a/magma my_container:/bin/magma
# Make sure you give yourself execution permissions when you're using it within the Docker container
docker exec -t -i upbeat_kowalevski chmod +x /bin/magma
If you get the error cannot execute binary file: Exec format error
when trying to run the executable, this probably indicates you added the executable for the wrong OS platform. Note that the OS within your Docker image can be different from the OS your computer runs on.
Sometimes you'll need root permissions to modify certain files or run certain commands. You'll need to do this outside the docker container (in your computer's Terminal/command line).
First find the randomly assigned name of your Docker image (e.g. "upbeat_kowalevski") in the Docker Desktop application. Then, in the command line, you can change file permissions like so:
docker exec -t -i <docker_image_name> chmod chmod +x <path/to/file>
You can also change permissions to many files/folders at once using the following command:
docker exec -t -i <docker_image_name> chmod -R u=rwx,go=rx <path/to/folder>
When setting up a new Docker env, you'll have to set up a new .Renviron file.
You only need to do this once. After that, you can just copy and paste the contents of the .Renviron file outside of your container into the .Renviron file inside your container.
# Takes you to GitHub website. Create a token and then copy it
usethis::create_github_token()
Now modify the .Renviron file within your container:
# Opens your .Renviron file. Edit it to include "GITHUB_PAT=<token>" in a new line (no quotes).
usethis::edit_r_environ()
- Home
- Useful Info
- To do list for new starters
- Recommended Reading
-
Computing
- Our Private Cloud System
- Cloud Computing
- Docker
- Creating a Bioconductor package
- PBS example scripts for the Imperial HPC
- HPC Issues list
- Nextflow
- Analysing TIP-seq data with the nf-core/cutandrun pipeline
- Shared tools on Imperial HPC
- VSCode
- Working with Google Cloud Platform
- Retrieving raw sequence data from the SRA
- Submitting read data to the European Nucleotide Archive
- R markdown
- Lab software
- Genetics
- Reproducibility
- The Lab Website
- Experimental
- Lab resources
- Administrative stuff