---
title: "Docker/Singularity Containers"
author: "
Authors: `r auths <- eval(parse(text = gsub('person','c',read.dcf('../DESCRIPTION', fields = 'Authors@R'))));paste(auths[names(auths)=='given'],auths[names(auths)=='family'], collapse = ', ')`
"
date: "Vignette updated: `r format( Sys.Date(), '%b-%d-%Y')`
"
output:
BiocStyle::html_document:
md_extensions: [
"-autolink_bare_uris"
]
vignette: >
%\VignetteIndexEntry{docker}
%\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
---
```{r setup, include=FALSE}
#### Package name ####
pkg <- read.dcf("../DESCRIPTION", fields = "Package")[1]
library(pkg, character.only = TRUE)
## Docker containers must be lowercase
pkg <- tolower(pkg)
#### Username of DockerHub account ####
docker_user <- "neurogenomicslab"
```
# DockerHub
`r pkg` is now available via
[DockerHub](https://hub.docker.com/repository/docker/`r docker_user`/`r pkg`)
as a containerised environment with Rstudio and
all necessary dependencies pre-installed.
## Installation
## Method 1: via Docker
First, [install Docker](https://docs.docker.com/get-docker/)
if you have not already.
Create an image of the [Docker](https://www.docker.com/) container
in command line:
```
docker pull `r docker_user`/`r pkg`
```
Once the image has been created, you can launch it with:
```
docker run \
-d \
-e ROOT=true \
-e PASSWORD="" \
-v ~/Desktop:/Desktop \
-v /Volumes:/Volumes \
-p 8787:8787 \
`r docker_user`/`r pkg`
```
### NOTES
* Make sure to replace `` above with whatever you want your password to be.
* Change the paths supplied to the `-v` flags for your particular use case.
* The `-d` ensures the container will run in "detached" mode,
which means it will persist even after you've closed your command line session.
* The username will be *"rstudio"* by default.
* Optionally, you can also install the [Docker Desktop](https://www.docker.com/products/docker-desktop)
to easily manage your containers.
## Method 2: via Singularity
If you are using a system that does not allow Docker
(as is the case for many institutional computing clusters),
you can instead [install Docker images via Singularity](https://sylabs.io/guides/2.6/user-guide/singularity_and_docker.html).
```
singularity pull docker://`r docker_user`/`r pkg`
```
## Usage
Finally, launch the containerised Rstudio by entering the
following URL in any web browser:
*http://localhost:8787/*
Login using the credentials set during the Installation steps.
# Session Info
```{r Session Info}
utils::sessionInfo()
```