---
title: "What is Docker and Why should I use it?"
output:
  dcTemplate::dc_lesson_template:
    fig_width: 6
    fig_height: 6
    highlight: pygments
---


```{r knitr_init, echo = FALSE, cache = FALSE}
library(knitr)

## Global options
options(max.print = "75")
opts_chunk$set(cache = TRUE,
               prompt = FALSE,
               tidy = TRUE,
               comment = "> #",
               message = FALSE,
               warning = FALSE)
opts_knit$set(width = 75)
```

## Lesson Objectives

- Understanding the basic idea of Docker
- Seeing the point of why Docker is useful


## Why would I want to use Docker?
Imagine you are working on an analysis in R and you send your code to a friend. 
Your friend runs exactly this code on exactly the same data set but gets a slightly
different result. This can have various reasons such as a different operating
system, a different version of an R package, et cetera.
Docker is trying to solve problems like that.

**A Docker container can be seen as a computer inside your computer**. The cool
thing about this virtual computer is that you can send it to your friends; And when
they start this computer and run your code they will get exactly the same results
as you did.

![Computerception](files/computer.jpg)

In short, you should use Docker because

- it allows you to **wrangle dependencies** starting from the operating system up 
to details such as R and Latex package versions
- it makes sure that your analyses are **reproducible**.

There are a couple of other points what Docker helps with:

- Portability: Since a Docker container can easily be send to another machine,
you can set up everything on your own computer and then run the analyses on e.g. a
more powerful machine.
- Sharability: You can send the Docker container to anyone (who knows how to
work with Docker).

## Basic vocabulary
The words *image* and *container* will come up a lot in the following. 
An instance of an image is called container. An image is the setup of the virtual
computer. If you run this image, you will have an instance of it, which we call
containter. You can have many running containers of the same image.
