<p>Your best bet for these things are GitHub searches.  Here is one example of mine for a container used to support a <a href="https://stat430.com" rel="nofollow noreferrer">class I teach</a>, building on <a href="https://github.com/stat430dspm/rocker-pl/blob/master/Dockerfile" rel="nofollow noreferrer">another Dockerfile from our Rocker Project</a>.  The link gives you the full details, but omitting bits for brevity here we have</p>

<pre><code>FROM rocker/r-ubuntu:18.04   

# Install required libraries -- using prebuild binaries where available
RUN apt-get update &amp;&amp; apt-get install -y \
    git \
    r-cran-data.table \
    r-cran-devtools \
    r-cran-doparallel \
    r-cran-dygraphs \
    r-cran-foreach \
    r-cran-fs \
    r-cran-future.apply \
    r-cran-gh \
    r-cran-git2r \
    r-cran-igraph \
    r-cran-memoise \
    r-cran-microbenchmark \
    r-cran-png \
    r-cran-rcpparmadillo \
    r-cran-rex \
    r-cran-rsqlite \
    r-cran-runit \
    r-cran-shiny \
    r-cran-stringdist \
    r-cran-testthat \
    r-cran-tidyverse \
    r-cran-tinytest \
    r-cran-xts \
    sqlite3 \
    sudo

# Install additional R packages from CRAN (on top of the ones 
# pre-built as r-cran-*)
RUN install.r bench diffobj flexdashboard lintr ttdo unix

# Install plr -- for now (?) from GH; also install visualTest
RUN installGithub.r stat430dspm/plr MangoTheCat/visualTest
</code></pre>

<p>That pretty much covers it as we </p>

<ul>
<li>use the PPA by Michael Rutter to get as much as we can for Ubuntu LTS (currently still 18.04) via prebuild .deb packages for Ubuntu</li>
<li>use the <a href="https://github.com/eddelbuettel/littler" rel="nofollow noreferrer">littler</a> script <code>install.r</code> to install some packages from CRAN</li>
<li>use another <a href="https://github.com/eddelbuettel/littler" rel="nofollow noreferrer">littler</a> script <code>installGithub.r</code> to install two more repos from GitHub </li>
</ul>

<p>That just shows my preferred rank-ordering: binaries over CRAN over GitHub.  The key point for your question is that these <a href="https://github.com/eddelbuettel/littler" rel="nofollow noreferrer">littler</a> scripts are also on the R-ver stack for Rocker.  But with r-ver you have to <em>very careful</em> about mixing as the release date is fixed with MRAN <em>by design</em>.  </p>

<p>(And in case anybody wants to know more about the <em>why</em> of <em>this</em> container, we just put a <a href="https://arxiv.org/abs/1912.11144" rel="nofollow noreferrer">pre-print on arXiv</a> -- but this is pretty specific to the testing and grading infrastructure we use.</p>
How do I Install R Github packages inside Docker
<p>I am trying to create a Docker image for my R script to schedule the R job on Google Cloud. I am currently testing it with a small R Script. The <code>docker build</code> commands fails at the step where I am installing the <code>rga</code> GitHub package. Below is my R script and the DockerFile:</p>

<p>R script:</p>

<pre><code>library(rga)
library(bigrquery)
bq_token()
rga.open(instance = "ga", where="~/ga.rga")

demoScheduleAPI &lt;- function(){
  search_perf &lt;- ga$getData(XXXX, batch = TRUE, walk = TRUE, 
                          start.date = "2020-01-15",
                          end.date = "2020-01-16",
                          metrics = "ga:searchUniques",
                          dimensions="ga:date,ga:hour,ga:searchKeyword, ga:searchCategory ,ga:dimension6,ga:dimension10")
  project &lt;- "bidone-data"
  insert_upload_job(project, "GA_Export_Prod_DataSet", "Test_Table123", search_perf)
}
</code></pre>

<p>Dockerfile</p>

<pre><code>FROM rocker/r-ver:3.6.1

RUN mkdir /home/bidone

RUN R -e "install.packages('bigrquery', repos='http://cran.rstudio.com/')"

RUN R -e "install.packages('devtools', repos='http://cloud.r-project.org')"

RUN R -e "devtools::install_github('skardhamar/rga')"

COPY .secrets /home/analysis/.secrets

COPY ga /home/analysis/ga

COPY DockerTest.R /home/analysis/DOckerTest.R

CMD R -e "source('/home/analysis/DockerTest.R')"
</code></pre>

<p>It does install devtools package, however when it tries to install the <code>rga</code> package from github, it gives the following error.</p>

<pre><code>&gt; devtools::install_github('skardhamar/rga')
Error in loadNamespace(name) : there is no package called ‘devtools’
Calls: :: ... loadNamespace -&gt; withRestarts -&gt; withOneRestart -&gt; doWithOneRestart
Execution halted
The command '/bin/sh -c R -e "devtools::install_github('skardhamar/rga')"' returned a non-zero code: 1
</code></pre>

<p>How can I fix this issue?</p>