<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/r-and-docker-2/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2018/03/r-and-docker.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>If you regularly have to deal with specific versions of R, or different package combinations, or getting R set up to work with other databases or applications then, well, it can be a pain. You could dedicate a special machine for each configuration you need, I guess, but that's expensive and impractical. You could set up virtual machines in the cloud which works well for one-off situations, but gets tedious having to re-configure a new VM each time. Or, you could use Docker containers, which were expressly designed to make it quick easy to configure and launch an independent and secure collection of software and services.</p>
<p>If you're new to the concept of Docker containers, here's a <a rel="nofollow" href="https://blogs.technet.microsoft.com/machinelearning/2018/03/15/demystifying-docker-for-data-scientists-a-docker-tutorial-for-your-deep-learning-projects/?WT.mc_id=Revolutions-blog-davidsmi" target="_blank">docker tutorial for data scientists</a>. But the concepts are pretty simple. At <a rel="nofollow" href="https://hub.docker.com/r/microsoft/cntk/" target="_blank">Docker hub</a>, you can search &quot;images&quot; — basically, bundles of software with pre-configured settings — contributed by the community and by vendors. (You'll be referring to the images by name, for example: <code>rocker/r-base</code>.) You can then create a &quot;container&quot; (a running instance of that image) on your machine with the <a rel="nofollow" href="https://docs.docker.com/install/" target="_blank">docker application</a>, or in the cloud using the tools offered by your provider of choice.</p>
<p>For R users, there's a wide array of pre-configured Docker images for R available <a rel="nofollow" href="http://dirk.eddelbuettel.com/blog/2014/10/23/#introducing_rocker" target="_blank">since 2014</a>, thanks to the <a rel="nofollow" href="https://www.rocker-project.org/" target="_blank">Rocker project</a>. You can <a rel="nofollow" href="https://hub.docker.com/u/rocker/" target="_blank">browse the rocker repository at Docker Hub</a> to see everything available, but it includes:</p>
<ul>
<li>Simple images containing just the <a rel="nofollow" href="https://hub.docker.com/r/rocker/r-base/" target="_blank">latest official R release</a> or the <a rel="nofollow" href="https://hub.docker.com/r/rocker/r-devel/" target="_blank">latest daily R build</a>.</li>
<li>Images containing both <a rel="nofollow" href="https://hub.docker.com/r/rocker/rstudio/" target="_blank">R and RStudio Server</a>.</li>
<li>Images with the <a rel="nofollow" href="https://hub.docker.com/r/rocker/tidyverse/" target="_blank">tidyverse suite of packages</a> pre-installed.</li>
<li><a rel="nofollow" href="https://hub.docker.com/r/rocker/r-ver/" target="_blank">Version-stable</a> images, snapshotted to specific R (and RStudio versions) and the R package ecosystem at specific points in time. If you retrieve one of these images using a <a rel="nofollow" href="https://hub.docker.com/r/rocker/r-ver/tags/" target="_blank">tag</a>, your docker image will always include the <strong>same</strong> software, even months or years down the line. These are perfect for production instances, where reproducibility is paramount.</li>
</ul>
<p>I find the images containing RStudio Server super convenient whenever I need to try out something in a specific R version. All I need to do is provide the image name to <a rel="nofollow" href="https://docs.microsoft.com/en-us/azure/container-instances/?WT.mc_id=Revolutions-blog-davidsmi" target="_blank">Azure Container Instances</a>, and make sure port 8787 is open:</p>
<div><a rel="nofollow" href="http://a6.typepad.com/6a0105360ba1c6970c01bb09fd0dde970d-pi" target="_blank"><img border="0" alt="Azure Container Instances" title="Azure Container Instances" src="http://a6.typepad.com/6a0105360ba1c6970c01bb09fd0dde970d-800wi"></a>
<div>Creating a container for R 3.4.1 with the tidyverse packages and RStudio Server.</div>
</div>
<p> </p>
<div><a rel="nofollow" href="http://a4.typepad.com/6a0105360ba1c6970c01b8d2e41a0c970c-pi" target="_blank"><img border="0" alt="Azure Container Instances" title="Azure Container Instances" src="http://a4.typepad.com/6a0105360ba1c6970c01b8d2e41a0c970c-800wi"></a>
<div>Be sure to open port 8787 here for browser access.</div>
</div>
<p>That's it for the configuration, and after the instance is ready (about 2 minutes) I can use a web browser to visit http://40.121.205.121:8787/ to find a completely fresh R instance and the RStudio IDE. (The actual IP address will be provided for you by Container Instances, and can be found in the Overview section for your instance in the Azure Portal.)</p>
<p>You can of course use other cloud providers as well: Andre Heiss provides this guide for setting up a <a rel="nofollow" href="https://www.andrewheiss.com/blog/2017/04/27/super-basic-practical-guide-to-docker-and-rstudio/" target="_blank">rocker image in Digital Ocean</a>, and also provides some handy tips for creating your own Docker Files to create custom images of your own design. For more on the Rocker project, follow the link below.</p>
<p>The Rocker Project: <a rel="nofollow" href="https://www.rocker-project.org/" target="_blank">Docker Containers for the R Environment</a></p>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2018/03/r-and-docker.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/aKBaC5-unRc" height="1"></a></div>