<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>dockerfile-method — dockerfile • containerit</title>

<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>

<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />

<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>

<!-- sticky kit -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>

<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>



<meta property="og:title" content="dockerfile-method — dockerfile" />

<meta property="og:description" content="Create a Dockerfile based on either a sessionInfo, a workspace or a file." />

<meta property="og:image" content="/logo.png" />
<meta name="twitter:card" content="summary" />



<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>

<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->


  </head>

  <body>
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">containerit</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.0</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <a href="../index.html">
    <span class="fa fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../articles/containerit.html">Get started</a>
</li>
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="../articles/basic.html">Basic introduction to package containerit</a>
    </li>
    <li>
      <a href="../articles/bioconductor.html">Using Bioconductor with containerit</a>
    </li>
    <li>
      <a href="../articles/container.html">Using the containerit Docker image</a>
    </li>
  </ul>
</li>
<li>
  <a href="../news/index.html">Changelog</a>
</li>
      </ul>
      
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/o2r-project/containerit">
    <span class="fa fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      
      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>dockerfile-method</h1>
    <small class="dont-index">Source: <a href='https://github.com/o2r-project/containerit/blob/master/R/dockerfile.R'><code>R/dockerfile.R</code></a></small>
    <div class="hidden name"><code>dockerfile.Rd</code></div>
    </div>

    <div class="ref-description">
    
    <p>Create a Dockerfile based on either a sessionInfo, a workspace or a file.</p>
    
    </div>

    <pre class="usage"><span class='fu'>dockerfile</span>(<span class='kw'>from</span> <span class='kw'>=</span> <span class='kw pkg'>utils</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/sessionInfo'>sessionInfo</a></span>(),
  <span class='kw'>image</span> <span class='kw'>=</span> <span class='fu'><a href='getImageForVersion.html'>getImageForVersion</a></span>(<span class='fu'><a href='getRVersionTag.html'>getRVersionTag</a></span>(<span class='no'>from</span>)),
  <span class='kw'>maintainer</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/Sys.info'>Sys.info</a></span>()<span class='kw'>[[</span><span class='st'>"user"</span>]], <span class='kw'>save_image</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
  <span class='kw'>envir</span> <span class='kw'>=</span> <span class='no'>.GlobalEnv</span>, <span class='kw'>env</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='kw'>generator</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/paste'>paste</a></span>(<span class='st'>"containerit"</span>,
  <span class='kw pkg'>utils</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/packageDescription'>packageVersion</a></span>(<span class='st'>"containerit"</span>))), <span class='kw'>soft</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
  <span class='kw'>offline</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>copy</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>container_workdir</span> <span class='kw'>=</span> <span class='st'>"/payload/"</span>,
  <span class='kw'>cmd</span> <span class='kw'>=</span> <span class='st'>"R"</span>, <span class='kw'>entrypoint</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>add_self</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>silent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
  <span class='kw'>predetect</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>versioned_libs</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
  <span class='kw'>versioned_packages</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>filter_baseimage_pkgs</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
    
    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>from</th>
      <td><p>The source of the information to construct the Dockerfile. Can be a <code>sessionInfo</code> object, a path to a file within the working direcotry, a <code>DESCRIPTION</code> file, or the path to a workspace). If <code>NULL</code> then no automatic derivation of dependencies happens. If a <code>DESCRIPTION</code> file, then the minimum R version (e.g. "R (3.3.0)") is used for the image version and all "Imports" are explicitly installed.</p></td>
    </tr>
    <tr>
      <th>image</th>
      <td><p>(<a href='From-class.html'>From</a>-object or character) Specifes the image that shall be used for the Docker container (<code>FROM</code> instruction).
By default, the image selection is based on the given session. Alternatively, use <code><a href='getImageForVersion.html'>getImageForVersion(..)</a></code> to get an existing image for a manually defined version of R, matching the version with tags from the base image rocker/r-ver (see details about the rocker/r-ver at <a href=''https://hub.docker.com/r/rocker/r-ver/''>'https://hub.docker.com/r/rocker/r-ver/'</a>). Or provide a correct image name yourself.</p></td>
    </tr>
    <tr>
      <th>maintainer</th>
      <td><p>Specify the maintainer of the Dockerfile. See documentation at <a href=''https://docs.docker.com/engine/reference/builder/#maintainer''>'https://docs.docker.com/engine/reference/builder/#maintainer'</a>. Defaults to <code>Sys.info()[["user"]]</code>. Can be removed with <code>NULL</code>.</p></td>
    </tr>
    <tr>
      <th>save_image</th>
      <td><p>When TRUE, it calls <a href='https://www.rdocumentation.org/packages/base/topics/save'>save.image</a> in the current working directory and copys the resulting <code>.RData</code> file to the container's working directory. The created file in the local working director will not be deleted.
 Alternatively, you can pass a list of objects to be saved, which may also include arguments to be passed down to <code>save</code>, e.g. <code>save_image = list("object1", "object2")</code>. You can configure the name of the file the objects are saved to by adding a file name to the list of arguments, e.g. <code>save_image = list("objectA", save_image_filename = "mydata.RData")</code>, in which case the file path must be in UNIX notation. Note that you may not use <code>save_image_filename</code> for other objects in your session!
<code>save</code> will be called with <code>envir</code>.</p></td>
    </tr>
    <tr>
      <th>envir</th>
      <td><p>The environment for <code>save_image</code>.</p></td>
    </tr>
    <tr>
      <th>env</th>
      <td><p>optionally specify environment variables to be included in the image. See documentation: <a href=''https://docs.docker.com/engine/reference/builder/#env'>'https://docs.docker.com/engine/reference/builder/#env</a></p></td>
    </tr>
    <tr>
      <th>soft</th>
      <td><p>(boolean) Whether to include soft dependencies when system dependencies are installed, default is no.</p></td>
    </tr>
    <tr>
      <th>offline</th>
      <td><p>(boolean) Whether to use an online database to detect system dependencies or use local package information (slower!), default is no.</p></td>
    </tr>
    <tr>
      <th>copy</th>
      <td><p>whether and how a workspace should be copied - values: "script", "script_dir" or a list of relative file paths to be copied, or <code>NA</code> ot disable copying of files</p></td>
    </tr>
    <tr>
      <th>container_workdir</th>
      <td><p>the working directory in the container, defaults to <code>/payload/</code> and must end with <code>/</code>. Can be skipped with value <code>NULL</code>.</p></td>
    </tr>
    <tr>
      <th>cmd</th>
      <td><p>The CMD statement that should be executed by default when running a parameter. Use <code><a href='CMD_Rscript.html'>CMD_Rscript(path)</a></code> in order to reference an R script to be executed on startup, <code><a href='CMD_Render.html'>CMD_Render(path)</a></code> to render an R Markdown document, or <code><a href='Cmd.html'>Cmd(command)</a></code> for any command. If <code>character</code> is provided it is passed wrapped in a <code><a href='Cmd.html'>Cmd(command)</a></code>.</p></td>
    </tr>
    <tr>
      <th>entrypoint</th>
      <td><p>the ENTRYPOINT statement for the Dockerfile</p></td>
    </tr>
    <tr>
      <th>add_self</th>
      <td><p>Whether to add the package containerit itself if loaded/attached to the session</p></td>
    </tr>
    <tr>
      <th>silent</th>
      <td><p>Whether or not to print information during execution</p></td>
    </tr>
    <tr>
      <th>predetect</th>
      <td><p>Extract the required libraries based on <code>library</code> calls using the package <code>automagic</code> before running a script/document</p></td>
    </tr>
    <tr>
      <th>versioned_libs</th>
      <td><p>[EXPERIMENTAL] Whether it shall be attempted to match versions of linked external libraries</p></td>
    </tr>
    <tr>
      <th>versioned_packages</th>
      <td><p>Whether it shall be attempted to match versions of R packages</p></td>
    </tr>
    <tr>
      <th>filter_baseimage_pkgs</th>
      <td><p>Do not add packages from CRAN that are already installed in the base image. This does not apply to non-CRAN dependencies, e.g. packages install from GitHub.</p></td>
    </tr>
    </table>
    
    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>An object of class Dockerfile</p>
    
    <h2 class="hasAnchor" id="based-on-sessioninfo"><a class="anchor" href="#based-on-sessioninfo"></a>Based on <code>sessionInfo</code></h2>

    
    <p>Use the current <code><a href='https://www.rdocumentation.org/packages/utils/topics/sessionInfo'>sessionInfo</a>)</code> to create a Dockerfile.</p>
    
    <h2 class="hasAnchor" id="based-on-a-workspace-directory"><a class="anchor" href="#based-on-a-workspace-directory"></a>Based on a workspace/directory</h2>

    
    <p>Given an existing path to a directory, the method tries to automatically find the main <code>R</code> file within that directory.
Files are searched recursively. The following types are supported:</p>
<ol>
<li><p>regular R script files, identified by file names ending in <code>.R</code></p></li>
<li><p>weaved documents, identified by file names ending in <a href='http://rmarkdown.rstudio.com/'>R Markdown</a> (<code>.Rmd</code>)</p></li>
</ol>
    <p>After identifying the main file, the process continues as described in the section file.
If both types are found, documents are given priority over scripts.
If multiple files are found, the first file as returned by <code><a href='https://www.rdocumentation.org/packages/base/topics/list.files'>dir</a></code> will be used.</p>
    
    <h2 class="hasAnchor" id="based-on-a-file"><a class="anchor" href="#based-on-a-file"></a>Based on a file</h2>

    
    <p>Given an executable <code>R</code> script or document, create a Dockerfile to execute this file.
This executes the whole file to obtain a complete <code>sessionInfo</code> object, see section "Based on <code>sessionInfo</code>", and copies required files and documents into the container.</p>
    

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'><span class='no'>dockerfile</span> <span class='kw'>&lt;-</span> <span class='fu'>dockerfile</span>()</div><div class='output co'>#&gt; INFO [2019-08-20 16:43:57] Going online? TRUE  ... to retrieve system dependencies (sysreq-api)
#&gt; INFO [2019-08-20 16:43:57] Trying to determine system requirements for the package(s) 'assertthat,automagic,backports,BiocManager,callr,cli,codetools,commonmark,crayon,curl,debugme,desc,devtools,digest,evaluate,fansi,formatR,fs,futile.logger,futile.options,glue,highlight,htmltools,httpuv,httr,jsonlite,knitr,lambda.r,later,magrittr,MASS,memoise,mime,miniUI,pillar,pkgbuild,pkgconfig,pkgdown,pkgload,prettyunits,processx,promises,ps,purrr,R6,Rcpp,rematch2,remotes,rjson,rlang,rmarkdown,roxygen2,rprojroot,rstudioapi,semver,sessioninfo,shiny,shinyFiles,stevedore,stringi,stringr,sysreqs,testthat,tibble,usethis,versions,whisker,withr,xfun,xml2,xtable,yaml' from sysreqs online DB
#&gt; INFO [2019-08-20 16:44:01] Adding CRAN packages: assertthat, automagic, backports, BiocManager, callr, cli, codetools, commonmark, crayon, curl, debugme, desc, devtools, digest, evaluate, fansi, formatR, fs, futile.logger, futile.options, glue, highlight, htmltools, httpuv, httr, jsonlite, knitr, lambda.r, later, magrittr, MASS, memoise, mime, miniUI, pillar, pkgbuild, pkgconfig, pkgdown, pkgload, prettyunits, processx, promises, ps, purrr, R6, Rcpp, rematch2, remotes, rjson, rlang, rmarkdown, roxygen2, rprojroot, rstudioapi, semver, sessioninfo, shiny, shinyFiles, stevedore, stringi, stringr, testthat, tibble, usethis, versions, whisker, withr, xfun, xml2, xtable, yaml
#&gt; INFO [2019-08-20 16:44:01] Adding GitHub packages: r-hub/sysreqs@3860f2b512a9c3bd3db6791c2ff467a1158f4048
#&gt; INFO [2019-08-20 16:44:01] Created Dockerfile-Object based on sessionInfo</div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='no'>dockerfile</span>)</div><div class='output co'>#&gt; FROM rocker/r-ver:3.6.1
#&gt; LABEL maintainer="daniel"
#&gt; RUN export DEBIAN_FRONTEND=noninteractive; apt-get -y update \
#&gt;   &amp;&amp; apt-get install -y git-core \
#&gt; 	libcurl4-openssl-dev \
#&gt; 	libssl-dev \
#&gt; 	libxml2-dev \
#&gt; 	make \
#&gt; 	pandoc \
#&gt; 	pandoc-citeproc
#&gt; RUN ["install2.r", "assertthat", "automagic", "backports", "BiocManager", "callr", "cli", "codetools", "commonmark", "crayon", "curl", "debugme", "desc", "devtools", "digest", "evaluate", "fansi", "formatR", "fs", "futile.logger", "futile.options", "glue", "highlight", "htmltools", "httpuv", "httr", "jsonlite", "knitr", "lambda.r", "later", "magrittr", "MASS", "memoise", "mime", "miniUI", "pillar", "pkgbuild", "pkgconfig", "pkgdown", "pkgload", "prettyunits", "processx", "promises", "ps", "purrr", "R6", "Rcpp", "rematch2", "remotes", "rjson", "rlang", "rmarkdown", "roxygen2", "rprojroot", "rstudioapi", "semver", "sessioninfo", "shiny", "shinyFiles", "stevedore", "stringi", "stringr", "testthat", "tibble", "usethis", "versions", "whisker", "withr", "xfun", "xml2", "xtable", "yaml"]
#&gt; RUN ["installGithub.r", "r-hub/sysreqs@3860f2b512a9c3bd3db6791c2ff467a1158f4048"]
#&gt; WORKDIR /payload/
#&gt; CMD ["R"]</div><div class='input'>
</div></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
    <h2>Contents</h2>
    <ul class="nav nav-pills nav-stacked">
      <li><a href="#arguments">Arguments</a></li>
      
      <li><a href="#value">Value</a></li>

      <li><a href="#based-on-sessioninfo">Based on <code>sessionInfo</code></a></li>

      <li><a href="#based-on-a-workspace-directory">Based on a workspace/directory</a></li>

      <li><a href="#based-on-a-file">Based on a file</a></li>
      
      <li><a href="#examples">Examples</a></li>
    </ul>

  </div>
</div>

      <footer>
      <div class="copyright">
  <p>Developed by Daniel Nuest, Matthias Hinz.</p>
</div>

<div class="pkgdown">
  <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
      </footer>
   </div>

  

  </body>
</html>

