docker for the user - microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker...

37
Docker for the UseR Noam Ross, nyhackr, 2018-07-10 @noamross

Upload: others

Post on 20-May-2020

36 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Docker for the UseRNoam Ross, nyhackr, 2018-07-10

@noamross

Page 2: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

@EcoHealthNYC ecohealthalliance.org

Page 3: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Building technical and community infrastructure for R to support

open, reproducible science

@rOpenSciropensci.org

Page 4: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

?

Page 5: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Virtual Machine Technologies

Page 6: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Virtual Machine Docker

A lighter weight framework for scalability

Page 7: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Scalability → Ubiquity → Galactic Conquest

Page 8: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

A bare minimum of vocabulary

image

container

Dockerfile

Docker Hub

a package defining a working environment

an instance of an image / a running image

a file with a series of commands to build an image

a website/repository for sharing Docker images

Page 9: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

A bare minimum of commands

docker pull [user/repo]

docker build [directory] -t [tag]

docker run [image] -p [ports] -v [volumes] [command] -d

docker stop [container]

Start a container from an image opening a set of ports linking a set volumes run a non-default command, detach

Get image from a repository

Make an image from a Docker file and give it a tag/name

Stop a running container

Page 10: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

A bare minimum of commands in Rlibrary(stevedore) # github.com/richfitz/stevedore `harbor`, and `docker` also options dc <- docker_client()

dc$image$pull(name = [user/repo])

dc$image$build(context = [directory])

my_container <- dc$container$run(image = [image], ports = [ports], volumes = [volumes], cmd = [command], detach = TRUE)

my_container$stop()

Page 11: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Now, let's use Docker to ...

Make a fixed working environment

Access a service outside of R

Create an R based service

Send our compute job somewhere else

Page 12: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Docker as a Fixed Working Environment

Page 13: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 14: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Getting people on the same page - within and across teams

Beaulieu-Jones & Greene (2017) doi:10.1038/nbt.3780

Page 15: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

rocker-project.org, github.com/rocker-org

Boettiger (2015) doi:10.1145/2723872.2723882Boettiger + Eddelbuettel (2017) arXiv:1410.0846 

Page 16: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 17: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Let's Demo!

Page 18: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

o2r.info/containerit

Reproducibility Helpers: Containerit to Capture Dependencies

Page 19: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

https://nanx.me/liftr

Reproducibility Helpers: Liftr for Dockerized R Markdown

Page 20: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

mybinder.org

Page 21: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 22: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 23: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Docker as provider of libraries/services

Page 24: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

External library/service examplesBrowser rendering services for web

scraping (splashr, RSelenium)

Geospatial Services (osrm)

ML Services (h2o)

Page 25: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Let's Demo!

Page 26: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Docker as a platform for R services/apps

Page 27: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Web Apps

APIs

IDEs

Types of R Services

Page 28: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Let's Demo!

Page 29: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 30: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Docker for deploying compute jobs

Page 31: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

library(future) library(future.apply) cl <- makeClusterPSOCK( workers = c("10.0.0.40", "10.0.0.43"), rscript = c("docker", "run", "henrikbengtsson/r-base-future", "Rscript"))

plan(cluster, workers = cl) result <-future.apply(1:10, a_long_function_run_in_docker)

An example with the future package

Page 32: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Docker for deploying compute jobs

Page 33: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Singularity

Don't need admin rights on computer to use

Less isolation - shares files with your system

For packaging up workflows, scripts, utilities

Targets scientific applications and computing clusters

Runs Docker images, too

syslab.io

Page 34: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 35: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start
Page 36: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

More Resources!

The Dockumentation: docs.docker.com

An rOpenSci Lesson:

ropenscilabs.github.io/r-docker-tutorial/

All links and resources mentioned here will be live tomorrow at:

github.com/noamross/nyhackr-docker-talk

Page 37: Docker for the UseR - Microsoft · docker pull [user/repo] docker build [directory] -t [tag] docker run [image] -p [ports] -v [volumes] [command] -d docker stop [container] Start

Thanks!@noamross

@EcoHealthNYC@rOpenSci