Â
These exercises follow the material in the Docker section of Reproducible R.
docker pull rocker/r-ver:4.2.3
docker images
docker run --rm -ti rocker/r-ver:4.2.3
# an R prompt should appear in the terminal allowing you to write R code
# navigate to 'r_course' directory in downloaded material
cd /PathToDownloadedCourse/Reproducible_R-master/r_course
docker build -t rocker/r-ver:4.2.3_v2 ./data/docker_exercise
docker images
# Code in terminal
docker run --rm -ti -v ./data:/home/local_data rocker/r-ver:4.2.3_v2
docker ps
# see the mounted files
docker exec 13223bfef159 ls home # this command contains the container ID from 'docker ps'
# you should see both the miniconda directory that was made in the Dockerfile and the 'local_data' directory that contians the mounted directory
# R code
# set working directory to be the mounted directory
setwd("home/local_data")
# see files in mounted folder
list.files()
library(ggplot2)
# make and save plot
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
ggsave("mpg_vs_weight.pdf")
# now look in the directory on your computer that is mounted and this plot should be there
# R code
library(Herper)
# the environment name and miniconda path set in the Dockerfile
::local_CondaEnv(new = "docker_exercises",
HerperpathToMiniConda = "/home/miniconda")
# test out samtools
system("samtools --version")
- push this image to Docker Hub
# Code in terminal
# log in and provide credentials used to sign into Docker Hub
# this will prompt you to enter username and password
docker login
# get image ID to tag and push
docker images
# tag the image you want to push with your Docker Hub username and a tag name after the colon
# the ID is from the 'docker images' command
docker tag a8954d8caa31 dougbarrows/r-ver_4.2.3_v2:topush
# push to Docker Hub
docker push dougbarrows/r-ver_4.2.3_v2:topush