Introduction

Containerit is also available itself as a ready-to-use Docker image from Docker Hub. This is useful if you do not want to install a full stack of packages in your local machine, but still trace a specific R session/script/document using a regular command line interface.

tl;dr - pull image and show Dockerfile on console

The following example pulls the geospatial variant of the containerit images, runs two R commands, and prints out the created Dockerfile to the console.

## geospatial: Pulling from o2rproject/containerit
## c5e155d5a1d1: Already exists
## 2524371be50d: Already exists
## 03321dce714a: Already exists
## f7183dc9df43: Already exists
## 8a94f51ef612: Already exists
## 0871071b8282: Already exists
## d20d9e24f0ce: Already exists
## ecd0c9d884a2: Already exists
## 34198166c3ef: Already exists
## 89978b67f5d2: Already exists
## 005de089cb1e: Already exists
## 5fe456ccc50f: Already exists
## a4bbc4ae328f: Pulling fs layer
## b648dceb1c63: Pulling fs layer
## 2801e53bec76: Pulling fs layer
## 9494b804300f: Pulling fs layer
## 2801e53bec76: Verifying Checksum
## 2801e53bec76: Download complete
## a4bbc4ae328f: Verifying Checksum
## a4bbc4ae328f: Download complete
## a4bbc4ae328f: Pull complete
## 9494b804300f: Download complete
## b648dceb1c63: Verifying Checksum
## b648dceb1c63: Download complete
## b648dceb1c63: Pull complete
## 2801e53bec76: Pull complete
## 9494b804300f: Pull complete
## Digest: sha256:98de04565b5c6df876a00f1283ed8d9f84d5ac3925ac7ddabfe0592b25b89724
## Status: Downloaded newer image for o2rproject/containerit:geospatial
## docker.io/o2rproject/containerit:geospatial
## 
## R version 3.5.3 (2019-03-11) -- "Great Truth"
## Copyright (C) 2019 The R Foundation for Statistical Computing
## Platform: x86_64-pc-linux-gnu (64-bit)
## 
## R is free software and comes with ABSOLUTELY NO WARRANTY.
## You are welcome to redistribute it under certain conditions.
## Type 'license()' or 'licence()' for distribution details.
## 
## R is a collaborative project with many contributors.
## Type 'contributors()' for more information and
## 'citation()' on how to cite R or R packages in publications.
## 
## Type 'demo()' for some demos, 'help()' for on-line help, or
## 'help.start()' for an HTML browser interface to help.
## Type 'q()' to quit R.
## 
## > library(sf); the_dockerfile <- containerit::dockerfile(); print(the_dockerfile);
## Linking to GEOS 3.5.1, GDAL 2.1.2, PROJ 4.9.3
## INFO [2019-08-20 14:45:10] Going online? TRUE  ... to retrieve system dependencies (sysreq-api)
## INFO [2019-08-20 14:45:10] Trying to determine system requirements for the package(s) 'assertthat,backports,class,classInt,crayon,curl,DBI,desc,digest,e1071,formatR,fs,futile.logger,futile.options,htmltools,httpuv,jsonlite,lambda.r,later,magrittr,mime,miniUI,pillar,pkgconfig,promises,R6,Rcpp,rlang,rprojroot,semver,sf,shiny,shinyFiles,stevedore,stringi,stringr,tibble,units,versions,xtable' from sysreqs online DB
## INFO [2019-08-20 14:45:13] Adding CRAN packages: assertthat, backports, class, classInt, crayon, curl, DBI, desc, digest, e1071, formatR, fs, futile.logger, futile.options, htmltools, httpuv, jsonlite, lambda.r, later, magrittr, mime, miniUI, pillar, pkgconfig, promises, R6, Rcpp, rlang, rprojroot, semver, sf, shiny, shinyFiles, stevedore, stringi, stringr, tibble, units, versions, xtable
## INFO [2019-08-20 14:45:13] Created Dockerfile-Object based on sessionInfo
## FROM rocker/r-ver:3.5.3
## LABEL maintainer="root"
## RUN export DEBIAN_FRONTEND=noninteractive; apt-get -y update \
##   && apt-get install -y gdal-bin \
##  libcurl4-openssl-dev \
##  libgdal-dev \
##  libgeos-dev \
##  libgeos++-dev \
##  libssl-dev \
##  libudunits2-dev \
##  make
## RUN ["install2.r", "assertthat", "backports", "class", "classInt", "crayon", "curl", "DBI", "desc", "digest", "e1071", "formatR", "fs", "futile.logger", "futile.options", "htmltools", "httpuv", "jsonlite", "lambda.r", "later", "magrittr", "mime", "miniUI", "pillar", "pkgconfig", "promises", "R6", "Rcpp", "rlang", "rprojroot", "semver", "sf", "shiny", "shinyFiles", "stevedore", "stringi", "stringr", "tibble", "units", "versions", "xtable"]
## WORKDIR /payload/
## CMD ["R"]
## > 
## > 
## 
## R version 3.5.3 (2019-03-11)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Debian GNU/Linux 9 (stretch)
## 
## Matrix products: default
## BLAS: /usr/lib/openblas-base/libblas.so.3
## LAPACK: /usr/lib/libopenblasp-r0.2.19.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] sf_0.7-4            containerit_0.6.0   futile.logger_1.4.3
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.1           pillar_1.3.1         compiler_3.5.3      
##  [4] later_0.8.0          formatR_1.6          futile.options_1.0.1
##  [7] class_7.3-15         tools_3.5.3          digest_0.6.18       
## [10] jsonlite_1.6         tibble_2.1.1         stevedore_0.9.1     
## [13] pkgconfig_2.0.2      rlang_0.3.4          shiny_1.3.2         
## [16] DBI_1.0.0            curl_3.3             e1071_1.7-1         
## [19] stringr_1.4.0        desc_1.2.0           fs_1.2.7            
## [22] shinyFiles_0.7.2     versions_0.3         grid_3.5.3          
## [25] classInt_0.3-1       rprojroot_1.3-2      R6_2.4.0            
## [28] semver_0.2.0         lambda.r_1.2.3       magrittr_1.5        
## [31] units_0.6-2          backports_1.1.4      promises_1.0.1      
## [34] htmltools_0.3.6      assertthat_0.2.1     mime_0.6            
## [37] xtable_1.8-4         httpuv_1.5.1         stringi_1.4.3       
## [40] miniUI_0.1.1.1       rjson_0.2.20         crayon_1.3.4        
## 
##                                             CRAN 
## "https://mran.microsoft.com/snapshot/2019-04-26"

Control output

By default the containerit images print the session info before R is terminated. You can disable this by setting the environment variable CONTAINERIT_SILENT. Combined with the --quiet option for R, this reduces the output to merely the Dockerfile

You can set the futile.logger threshold with the environment variable CONTAINERIT_FLOG_THRESHOLD to ERROR, WARN or DEBUG; default is INFO.

Build image locally

With the following commands you can build an image from the local source code. The following commands executed in the containerit source directory create an image containerit:geo-manual and run it to create a Dockerfile:

You can try the predetect feature by packaging the R Markdown file of the second spacetime vignette with the non-geospatial image of containerit that was just built. The following command will install missing packages before running the file, namely sf itself, but it’s installation will fail due to missing system dependencies, which are not covered by predetection.