Top Banner
ICWE 2016, Lugano Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW Using Docker Containers to Improve Reproducibility in Software and Web Engineering Jürgen Cito, Vincenzo Ferme, Harald C. Gall
218

Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Jan 11, 2017

Download

Technology

Vincenzo Ferme
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

ICWE 2016, Lugano

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

Page 2: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

2

Jürgen Cito PhD @ UZH

Vincenzo Ferme PhD @ USI

The speakers

Page 3: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

3

This tutorial…

Conceptual, more abstract

notion of Reproducibility

Concrete instructions

to aid Reproducibility in

Research & Industry

Page 4: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

4

Agenda

Part I:What is Reproducibility? A theoretical perspective

Page 5: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

4

Agenda

Part I:What is Reproducibility? A theoretical perspective

Part II:Docker to Aid Reproducibility Basics and Case Study 1 (Research Project Case Study)

Page 6: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

4

Agenda

Part I:What is Reproducibility? A theoretical perspective

Part II:Docker to Aid Reproducibility Basics and Case Study 1 (Research Project Case Study)

Part III:Docker to Aid Reproducibility Advanced Topics and Case Study 2 (Industrial Case Study)

Page 7: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

Part I - What is Reproducibility?

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

ICWE 2016, Lugano

Page 8: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

6

Reproducibility is the ability of an entire experiment or study to be duplicated, either by the same researcher or by someone else working independently.

Reproducing an experiment is called replicating it.

What is Reproducibility?

No research paper can ever be consideredto be the final word, and the replication and corroboration of research results is key to the scientific process.

Page 9: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

7

What is Reproducibility?

Repeatability of a certain process in order to establish a fact or the conditions under which we are able to observe the same fact*

A process to share methods, and describe the environment, in order to recreate results.

* Mockus et al. “Experiences from replicating a case study to investigate reproducibility of software development.”

Page 10: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

8

Scientific Process

Experiment Design

Data Collection

Data Analysis

Results Interpretation

Hypotheses

Reproducibility

Page 11: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

9

What is Reproducibility?

Establishing facts > Steps (or a method) to establish the fact > Sharing computational knowledge

Page 12: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

9

What is Reproducibility?

Establishing facts > Steps (or a method) to establish the fact > Sharing computational knowledge

Controlling environment > Execution environment> Dependencies

Page 13: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

9

What is Reproducibility?

Establishing facts > Steps (or a method) to establish the fact > Sharing computational knowledge

Controlling environment > Execution environment> Dependencies

Providing data > Ability to interpret data > Computational analyses

Page 14: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

9

What is Reproducibility?

Establishing facts > Steps (or a method) to establish the fact > Sharing computational knowledge

Controlling environment > Execution environment> Dependencies

Providing data > Ability to interpret data > Computational analyses

Low barriers to replicate > Comprehensible results> Ease of achieving replication

Page 15: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

10

What is Reproducibility in SE/WE Research?

Algorithms / Computational Analyses

Developed Tools or Prototypes

Quantitative Evaluations

+ internal knowledge of the necessary process to derive/establish results

Page 16: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

11

In Software Engineering Research:- FSE’15/16, MSR’15/16

In Programming Languages Research:- PLDI, POPL, OOPSLA

Artifact Evaluation & Replication Packages

Page 17: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

12

Current State of Sharing Artefacts

Researcher’s website

Page 18: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

Part II - Research Project Case Study

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

ICWE 2016, Lugano

Page 19: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

14

Case Study 1: ChangeDistiller

https://bitbucket.org/sealuzh/tools-changedistiller

Research Project

Page 20: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

15

Why is reproducibility hard?

Why does it fail?

Page 21: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

16

Reasons for Failed Reproducibility (1/2)

*https://twitter.com/ianholmes/status/288689712636493824

Page 22: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

17Source: Collberg et al., “Measuring Reproducibility in Computer Systems Research”, http://reproducibility.cs.arizona.edu/tr.pdf

Reasons for Failed Reproducibility (2/2)

Page 23: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

18

Case Study 1: ChangeDistiller

https://bitbucket.org/sealuzh/tools-changedistiller

Research Project

- Developed 2006-2009 How many Java versions have we passed?

- Dependencies defined in a Maven pom file Are they all still available in the repository?

- How does analysis in ChangeDistiller work?What is the entry point?

Page 24: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

19

Challenges in Reproducibility

Page 25: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

19

> No standard way of describing experiments, environments, (derived) data, and workflows

Challenges in Reproducibility

Page 26: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

19

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis

Challenges in Reproducibility

Page 27: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

19

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis

> The experimental nature of the research code and ecosystems makes it often hard to build

Challenges in Reproducibility

Page 28: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

19

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis

> The experimental nature of the research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

Challenges in Reproducibility

Page 29: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

19

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis

> The experimental nature of the research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

> Infrastructure for storage and distribution

Challenges in Reproducibility

Page 30: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

20

… to the rescue

Page 31: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

21

Docker Containers to the rescue (1/2)

What is Docker?

Docker allows you to package an application with all of its dependencies into a standardized unit for software development*

Containers consist of everything that enables software to run:> Code> Runtime> System Tools > System Libraries

* https://www.docker.com/what-docker

Page 32: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

22

Docker Containers to the rescue (2/2)

What can Docker be for SE/WE research?

Docker allows you to package a - Prototype

- Proof-of-concept Implementation - Computational analysis or experiment

with all of its dependencies into a standardized unit for reproducible research

* https://www.docker.com/what-docker

Page 33: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Technical Overview / Virtual Machines vs Containers

“Lightweight” VM > Container is an isolated process (“chroot on steroids”)> Own process space > Own network interface > Feels like a VM > Shares kernel with the host > Isolation through cgroups/namespaces

23

https://www.docker.com/what-is-docker

https://blog.docker.com/2016/03/containers-are-not-vms/

Page 34: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

24

Docker Engine

Centralized runtime environment for containers

Enables portability

Sole dependency for Docker

No Emulation layer (almost no performance impact)

https://www.docker.com/products/docker-engine

Page 35: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

25

Benefits of Docker Containers (compared to VMs)

Fast instantiation (~1-3 seconds)

Almost native performance

Transparent build process

Smaller Images

Easy to build, share, and publish

* https://www.docker.com/what-docker

Page 36: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

25

Benefits of Docker Containers (compared to VMs)

Fast instantiation (~1-3 seconds)

Almost native performance

Transparent build process

Smaller Images

Easy to build, share, and publish

* https://www.docker.com/what-docker

also compared to

other container te

chnologies

Page 37: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

26

Single Container Docker Workflow

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container

run

Page 38: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

27

Dockerfile Declarative definition of an environment for producing an imageDocker Image Immutable artifact built from a Dockerfile, has one to many layers

Docker ContainerExecution environment - Instantiation/running version of an image (can be parameterized)

Docker MachineCreates Docker hosts on your local Mac or Windows box

Docker RegistryPublic or private repository stores images and allows for their distribution(Docker Hub - https://hub.docker.com/ or CoreOS Quay - https://quay.io/)

Terminology

Page 39: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

build

28

Single Container Docker Workflow

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

Image

Docker Image Docker Container

run

Page 40: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Page 41: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Base Image

Page 42: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Base ImageBase Image can be an OS (Ubuntu)

or a different, existing image

Page 43: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base ImageBase Image can be an OS (Ubuntu)

or a different, existing image

Page 44: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base ImageBase Image can be an OS (Ubuntu)

or a different, existing image

Runs commands as if you were typing them in the command line

Page 45: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base Image

Install

Base Image can be an OS (Ubuntu) or a different, existing image

Runs commands as if you were typing them in the command line

Page 46: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base Image

Install

Base Image can be an OS (Ubuntu) or a different, existing image

Runs commands as if you were typing them in the command line

Copies local files from build context into container

Page 47: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base Image

Install

Volume

Base Image can be an OS (Ubuntu) or a different, existing image

Runs commands as if you were typing them in the command line

Copies local files from build context into container

Page 48: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base Image

Install

Open PortVolume

Base Image can be an OS (Ubuntu) or a different, existing image

Runs commands as if you were typing them in the command line

Copies local files from build context into container

Page 49: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

29

DockerfileDefines the infrastructure and dependencies of a container through instructions

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

COPY redis.conf /var/www/redis.conf

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dependencies

Base Image

Install

Open Port

Start Server

Volume

Base Image can be an OS (Ubuntu) or a different, existing image

Runs commands as if you were typing them in the command line

Copies local files from build context into container

Page 50: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

30

Data Volumes

A specially-designated directory within one or more containers that bypasses the Union File System*

Volumes allow you to manage data within containers > Mount a host directory (dependency to the host filesystem)> Mount a data volume container (dependency to another container)> Mount a shared-storage volume (NFS, iSCSI, etc.)

* https://docs.docker.com/engine/userguide/containers/dockervolumes/

Page 51: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

31

Single Container Docker Workflow

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container

run

Page 52: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

32

Dockerfile —> ImageDefines the infrastructure and dependencies of a container through instructions

docker build -t <imagename> .

Page 53: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

32

Dockerfile —> ImageDefines the infrastructure and dependencies of a container through instructions

docker build -t <imagename> .

Build Context containing all local dependencies and

Dockerfile

Page 54: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

33

Docker Images

# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmhart/alpine-node latest 2a15d8568f75 1 week ago 36.76 MBhakyll latest d575da1e730c 2 weeks ago 1.487 GBredis alpine 50405530a7e5 4 weeks ago 15.95 MB

# docker rmi hakyllUntagged: hakyll:latestDeleted: sha256:3240943c9ea3f72db51…Deleted: sha256:a3aeefae0d4b8f61…Deleted: sha256:16a7ebd378002f1261…

Page 55: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

33

Docker Images

# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmhart/alpine-node latest 2a15d8568f75 1 week ago 36.76 MBhakyll latest d575da1e730c 2 weeks ago 1.487 GBredis alpine 50405530a7e5 4 weeks ago 15.95 MB

# docker rmi hakyllUntagged: hakyll:latestDeleted: sha256:3240943c9ea3f72db51…Deleted: sha256:a3aeefae0d4b8f61…Deleted: sha256:16a7ebd378002f1261…

Lists all previously built images

Page 56: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

33

Docker Images

# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmhart/alpine-node latest 2a15d8568f75 1 week ago 36.76 MBhakyll latest d575da1e730c 2 weeks ago 1.487 GBredis alpine 50405530a7e5 4 weeks ago 15.95 MB

# docker rmi hakyllUntagged: hakyll:latestDeleted: sha256:3240943c9ea3f72db51…Deleted: sha256:a3aeefae0d4b8f61…Deleted: sha256:16a7ebd378002f1261…

Lists all previously built images

Removes an image ‘hakyll:latest’

and all its layers from the disk

Page 57: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

34

Single Container Docker Workflow

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image

run

Docker Container

Page 58: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

35

Image —> Container

docker run -d --name <containername> -p 80:5000 <imagename>

https://docs.docker.com/engine/reference/run/Many more possibilities to run containers, see full reference here:

(A typical example)

Page 59: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

35

Image —> Container

docker run -d --name <containername> -p 80:5000 <imagename>

Run container in the background (d for daemon)

https://docs.docker.com/engine/reference/run/Many more possibilities to run containers, see full reference here:

(A typical example)

Page 60: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

35

Image —> Container

docker run -d --name <containername> -p 80:5000 <imagename>

Run container in the background (d for daemon)

https://docs.docker.com/engine/reference/run/

Give the container a unique name

Many more possibilities to run containers, see full reference here:

(A typical example)

Page 61: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

35

Image —> Container

docker run -d --name <containername> -p 80:5000 <imagename>

Run container in the background (d for daemon)

https://docs.docker.com/engine/reference/run/

Give the container a unique name

Port mappingFirst the exposed port (80)

Second the port within the container (5000)

Many more possibilities to run containers, see full reference here:

(A typical example)

Page 62: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

36

Container Managementdocker ps

docker ps -a

docker stop <container>

docker rm <container>

docker rm -v <container>

Page 63: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

36

Container Managementdocker psLists all running containers

docker ps -a

docker stop <container>

docker rm <container>

docker rm -v <container>

Page 64: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

36

Container Managementdocker psLists all running containers

docker ps -aLists all containers (including the ones that are stopped)

docker stop <container>

docker rm <container>

docker rm -v <container>

Page 65: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

36

Container Managementdocker psLists all running containers

docker ps -aLists all containers (including the ones that are stopped)

docker stop <container>Stops a running container

docker rm <container>

docker rm -v <container>

Page 66: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

36

Container Managementdocker psLists all running containers

docker ps -aLists all containers (including the ones that are stopped)

docker stop <container>Stops a running container

docker rm <container>Removes a stopped container

docker rm -v <container>

Page 67: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

36

Container Managementdocker psLists all running containers

docker ps -aLists all containers (including the ones that are stopped)

docker stop <container>Stops a running container

docker rm <container>Removes a stopped container

docker rm -v <container>Removes a stopped container and its volumes

Page 68: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

37

Container Debugging

docker run -ti --entrypoint=bash <imagename>

docker exec -ti <container> bash

docker inspect <container>

docker logs <container>

Page 69: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

37

Container Debugging

docker run -ti --entrypoint=bash <imagename>

docker exec -ti <container> bash

docker inspect <container>Low-level information on a container or image

docker logs <container>

Page 70: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

37

Container Debugging

docker run -ti --entrypoint=bash <imagename>

docker exec -ti <container> bash

docker inspect <container>Low-level information on a container or image

docker logs <container>Retrieves logs printed to stdout/err within the container

Page 71: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

37

Container Debugging

docker run -ti --entrypoint=bash <imagename>

docker exec -ti <container> bashStarts an interactive shell into a running container

docker inspect <container>Low-level information on a container or image

docker logs <container>Retrieves logs printed to stdout/err within the container

Page 72: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

37

Container Debugging

docker run -ti --entrypoint=bash <imagename>Starts a container with a different entrypoint

docker exec -ti <container> bashStarts an interactive shell into a running container

docker inspect <container>Low-level information on a container or image

docker logs <container>Retrieves logs printed to stdout/err within the container

Page 73: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

38

Docker Hub: Public Registry

Page 74: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

39

Pulling Docker Images Getting started with existing images

docker pull nginx:latest

Page 75: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

40

Pulling Docker Images Getting started with existing images

docker pull nginx:latestReference to a Docker Image in the Docker Hub

Page 76: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

41

Pulling Docker Images Getting started with existing images

docker pull nginx:latestImages can have many “tags”

Page 77: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

42

Pulling Docker Images Getting started with existing images

docker pull nginx:latestPulls an image from a Docker registry

Page 78: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

43

Pushing Docker Images to a Registry Tag Image

docker tag c6fdd6639541 <username>/<imagename>:<tagname>

Image Id (retrieve through )docker images

Page 79: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

44

Pushing Docker Images to a Registry Push Image

Page 80: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

44

Pushing Docker Images to a Registry Push Image

docker login --username=<username> --email=<email>

Page 81: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

44

Pushing Docker Images to a Registry Push Image

docker login --username=<username> --email=<email>

docker push <username>/<imagename>:<tagname>

Page 82: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

45

Case Study 1: ChangeDistiller

https://bitbucket.org/sealuzh/tools-changedistiller

Research Project

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container

run

Page 83: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

46

Prerequisites for attending the tutorial

Prerequisites

• git on your terminal

• OSX or Windows: Docker Toolbox, https://www.docker.com/products/docker-toolbox. Then follow the getting started guide on the same page.

• Linux: 1) https://docs.docker.com/linux/, 2) https://docs.docker.com/machine/install-machine/, 3) https://docs.docker.com/compose/install/

Git clone

• git clone https://github.com/ICWE2016DockerTutorial/ChangeDistiller.git

• git clone https://github.com/ICWE2016DockerTutorial/NodeJSApp.git

• git clone https://github.com/ICWE2016DockerTutorial/MongoDB.git

PDF on: http://icwe2016.inf.usi.ch/program/tutorials/docker

Page 84: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

47

Case Study 1: ChangeDistiller

https://goo.gl/3h7DGA

We paste the commands we run, live at the following url:

Page 85: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Page 86: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Base Image

Page 87: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Copy sources

Base Image

Page 88: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Copy sources

Base Image

Dependencies

Page 89: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Copy sources

Base Image

Install

Dependencies

Page 90: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Copy sources

Base Image

Install

Dependencies

Volume for generated files

Page 91: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

48

Case Study 1: ChangeDistiller

(Simple) Dockerfile for ChangeDistiller

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Copy sources

Base Image

Install

Start/enter at analysis

Dependencies

Volume for generated files

Page 92: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

49

Case Study 1: ChangeDistiller

docker build -t icwe2016dockertutorial/changedistiller:master .Executes in the folder with the Dockerfile. Creates an image

Illustrative execution of Docker commands

docker run --name cd icwe2016dockertutorial/changedistiller:masterCreates the container and runs the analysis

Context

cd ChangeDistiller

Page 93: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

50

Case Study 1: ChangeDistiller Version Pinning

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven=3.0.5-3 RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Page 94: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

50

Case Study 1: ChangeDistiller Version Pinning

FROM java:openjdk-7u101-jdk

ENV app_dir /usr/src/changedistiller

COPY . ${app_dir} WORKDIR ${app_dir}

RUN apt-get update && apt-get install -y maven=3.0.5-3 RUN ${app_dir}/build.sh RUN mvn install

VOLUME ${app_dir}/target

ENTRYPOINT ["mvn", "test"]

Version Pinning for Dependencies

Page 95: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

51

Docker Hub: Automated/Trusted Build Improves transparency

https://docs.docker.com/docker-hub/builds/

Docker Hub

Page 96: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

51

Docker Hub: Automated/Trusted Build Improves transparency

https://docs.docker.com/docker-hub/builds/

Docker Hubpush

Page 97: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

51

Docker Hub: Automated/Trusted Build Improves transparency

https://docs.docker.com/docker-hub/builds/

Docker Hubbuildpush

Page 98: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Recap: Challenges in Reproducibility

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis> Experimental nature of research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

> Trusted infrastructure for storage and distribution

52

Page 99: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Recap: Challenges in Reproducibility

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis> Experimental nature of research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

> Trusted infrastructure for storage and distribution

Dockerfile

Dockerfile

52

Page 100: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Recap: Challenges in Reproducibility

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis> Experimental nature of research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

> Trusted infrastructure for storage and distribution

Dockerfile

Docker Image

Dockerfile

52

Page 101: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Recap: Challenges in Reproducibility

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis> Experimental nature of research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

> Trusted infrastructure for storage and distribution

Dockerfile

Docker Image

Docker Container

Dockerfile

52

Page 102: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Recap: Challenges in Reproducibility

> No standard way of describing experiments, environments, (derived) data, and workflows

> No transparency in creating environments and the steps/methods to establish facts or recreate analysis> Experimental nature of research code and ecosystems makes it often hard to build

> Unresolved or undocumented dependencies

> Trusted infrastructure for storage and distribution

Dockerfile

Docker Image

Docker Container

Registries (Docker Hub, Quay, …)

Dockerfile

52

Page 103: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

ICWE 2016, Lugano

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

\

Question Time!

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

Page 104: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

54

Part III - Multi Containers Docker Application Preview

Reproduce Bugs present in a Version of a CRUD Web Application54

Redis

NodeJS App

MongoDB

network

Page 105: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

54

Part III - Multi Containers Docker Application Preview

Reproduce Bugs present in a Version of a CRUD Web Application54

Redis

NodeJS App

link

MongoDB

link

network

Page 106: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

54

Part III - Multi Containers Docker Application Preview

Reproduce Bugs present in a Version of a CRUD Web Application54

Redis

NodeJS App

link

MongoDB

link

network

Docker Compose

Page 107: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

ICWE 2016, Lugano

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

End of Part II - Lunch Break!

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

Page 108: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

ICWE 2016, Lugano

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

Part III - Industrial Case Study

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

Page 109: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

57

What is Reproducibility?

Page 110: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

57

What is Reproducibility?

Challenges in Reproducibility

Page 111: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

57

What is Reproducibility?

Single Container Docker Workflow# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container

run

Challenges in Reproducibility

Page 112: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

58

Multi Containers Docker Workflow# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container 1

run

Page 113: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

58

Multi Containers Docker Workflow

Docker HubDocker Container 2

run

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container 1

run

Page 114: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

network

58

Multi Containers Docker Workflow

Docker HubDocker Container 2

run

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container 1

run

Page 115: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

network

58

Multi Containers Docker Workflow

Docker HubDocker Container 2

run

link

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget

RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz

# RUN tar -zvzf /redis/redis-stable.tar.gz RUN (cd /redis-stable && make) RUN (cd /redis-stable && make test)

RUN mkdir -p /redis-data VOLUME ["/redis-data"] EXPOSE 6379

ENTRYPOINT ["/redis-stable/src/redis-server"] CMD ["--dir", "/redis-data"]

Dockerfile

build

Image

Docker Image Docker Container 1

run

Page 116: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

59

Case Study 2: NodeJS + MongoDB + Redis

Reproduce Bugs present in a Version of a CRUD Web Application

Redis

NodeJS App

MongoDB

network

Page 117: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

59

Case Study 2: NodeJS + MongoDB + Redis

Reproduce Bugs present in a Version of a CRUD Web Application

Redis

NodeJS App

link

MongoDB

link

network

Page 118: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

60

Case Study 2: NodeJS + MongoDB + Redis

Reproduce Bugs present in a Version of a CRUD Web Application

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 119: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

60

Case Study 2: NodeJS + MongoDB + Redis

Reproduce Bugs present in a Version of a CRUD Web Application

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Custom Schema and Data

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 120: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

60

Case Study 2: NodeJS + MongoDB + Redis

Reproduce Bugs present in a Version of a CRUD Web Application

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Custom Schema and Data

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 121: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

61

Docker Networks

docker network ls

Page 122: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

61

Docker Networks

NETWORK ID NAME DRIVERbbd6e3c22dad bridge bridged0bcac7befe4 host hosta4f078c19762 none null

docker network ls

Page 123: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

61

Docker Networks

docker network create icwe2016Creates a bridge network named icwe2016

NETWORK ID NAME DRIVERbbd6e3c22dad bridge bridged0bcac7befe4 host hosta4f078c19762 none null

docker network ls

Page 124: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

61

Docker Networks

docker network create icwe2016Creates a bridge network named icwe2016

NETWORK ID NAME DRIVERbbd6e3c22dad bridge bridged0bcac7befe4 host hosta4f078c19762 none null

docker network ls

docker network create -d overlay icwe2016Creates an overlay network named icwe2016

Page 125: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

62

Docker Networks

docker network create icwe2016

Page 126: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

62

Docker Networks

docker network create icwe2016

icwe2016

Page 127: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

62

Docker Networks

docker network create icwe2016

icwe2016

docker network connect icwe2016 NodeJSAppConnects NodeJSApp to the icwe2016 network

icwe2016

Page 128: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

62

Docker Networks

docker network create icwe2016

icwe2016

docker network connect icwe2016 NodeJSAppConnects NodeJSApp to the icwe2016 network

icwe2016NodeJS App

Page 129: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

63

Docker Networks

icwe2016NodeJS App

https://docs.docker.com/engine/reference/commandline/network_create/Many more possibilities for networks, see full reference here:

Page 130: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

63

Docker Networks

icwe2016NodeJS App

docker run -d --net icwe2016 ... MongoDBStarts and connects MongoDB to the icwe2016 network

https://docs.docker.com/engine/reference/commandline/network_create/Many more possibilities for networks, see full reference here:

Page 131: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

63

Docker Networks

icwe2016NodeJS App

docker run -d --net icwe2016 ... MongoDBStarts and connects MongoDB to the icwe2016 network

MongoDB

https://docs.docker.com/engine/reference/commandline/network_create/Many more possibilities for networks, see full reference here:

Page 132: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

64

Docker Networks

icwe2016

NodeJS App MongoDB

EXPOSE 27017

Page 133: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

64

Docker Networks

icwe2016

NodeJS App MongoDB

mongodb:27017 EXPOSE 27017

link

Page 134: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

64

Docker Networks

icwe2016

NodeJS App MongoDB

mongodb:27017 EXPOSE 27017

link

Docker takes care of:

• adding the relevant reference to your container’s /etc/hosts

• keeping the link valid across linked containers’ restarts

Page 135: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

65

Case Study 2: NodeJS + MongoDB + Redis

Reproduce Bugs present in a Version of a CRUD Web Application

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Custom Schema and Data

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 136: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

66

Case Study 2: NodeJS + MongoDB + Redis

https://goo.gl/3h7DGA

We paste the commands we run, live at the following url:

Page 137: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

67

Case Study 2: Web Application

https://github.com/scotch-io/node-todoRepo with the Application we have started from:

Page 138: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

67

Case Study 2: Web Application

https://github.com/scotch-io/node-todoRepo with the Application we have started from:

Page 139: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

67

Case Study 2: Web Application

https://github.com/scotch-io/node-todoRepo with the Application we have started from:

Page 140: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

67

Case Study 2: Web Application

https://github.com/scotch-io/node-todoRepo with the Application we have started from:

+ a couple of bugs, one client-side and one server-side

Page 141: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

68

Case Study 2: NodeJS + MongoDB + Redis

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Custom Schema and Data

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 142: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

69

Case Study 2: NodeJS App Relevant files for Docker

config/database.js

config/redis.js

bin/*

Page 143: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

Page 144: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

Base Image

Page 145: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Page 146: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Install Dependencies

Page 147: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Install Dependencies

Copy App.

Page 148: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Install Dependencies

Copy App.

Utility

Utility

Page 149: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Install Dependencies

Copy App.

Private Port

Utility

Utility

Page 150: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Install Dependencies

Copy App.

Enter

Private Port

Utility

Utility

Page 151: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

70

Case Study 2: NodeJS App(Simple) Dockerfile for NodeJS App

FROM node:6.2.0

RUN mkdir -p /usr/src/app WORKDIR /usr/src/app

COPY package.json /usr/src/app/ RUN npm install

COPY . /usr/src/app

COPY ./bin/wait-for-it.sh / RUN chmod +x /wait-for-it.sh

COPY ./bin/wait-for-mongo-redis.sh / RUN chmod +x /wait-for-mongo-redis.sh

EXPOSE 3000

ENTRYPOINT [ "/wait-for-mongo-redis.sh" ] CMD [ "npm", "start" ]

App. Dir.

Base Image

Install Dependencies

Copy App.

Enter Start

Private Port

Utility

Utility

Page 152: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

71

Case Study 2: NodeJS App

docker build -t icwe2016dockertutorial/nodejsapp:master .

Illustrative execution of Docker commands

Context

cd NodeJSApp

Page 153: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

72

Case Study 2: NodeJS + MongoDB + Redis

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Custom Schema and Data

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 154: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

73

Case Study 2: MongoDB Relevant files for Docker

data/*

bin/*

Page 155: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Page 156: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Base Image

Page 157: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Base Image Defines also the private port

Page 158: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Base Image

Copy Data

Defines also the private port

Page 159: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Base Image

Utility

Copy Data

Defines also the private port

Page 160: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Base Image

Utility

Copy Data

Enter

Defines also the private port

Page 161: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

74

Case Study 2: MongoDB(Simple) Dockerfile for MongoDB with Seed data

FROM mongo:3.3.6

COPY data/seed/icwe2016dockertutorial /data/db/icwe2016dockertutorial

COPY bin/initialize-mongo.sh /initialize-mongo.sh RUN chmod +x /initialize-mongo.sh

ENTRYPOINT ["/initialize-mongo.sh"] CMD ["mongod"]

Base Image

Utility

Copy Data

Enter Start

Defines also the private port

Page 162: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

75

Case Study 2: MongoDB

docker build -t icwe2016dockertutorial/mongodb:master .

Illustrative execution of Docker commands

Context

cd MongoDB

Page 163: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

76

Case Study 2: NodeJS + MongoDB + Redis

Redis

NodeJS App

link

MongoDB

link

network

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Custom Schema and Data

# Build redis from source # Make sure you have the redis source code checked out in # the same directory as this Dockerfile

FROM ubuntu:12.04 MAINTAINER dockerfiles http://dockerfiles.github.io

RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get upgrade -y

Web App

Page 164: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Illustrative execution of Docker commands

77

Case Study 2: Redis

docker pull redis:3.2.0-alpine

Page 165: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

78

Case Study 2: Starting the NodeJS App

docker run -d --net icwe2016 --name mongodb icwe2016dockertutorial/mongodb:masterdocker

docker network create icwe2016

docker run -d --net icwe2016 --name redis redis:3.2.0-alpine

docker run -d --net icwe2016 -p 8080:3000 --name nodejsapp icwe2016dockertutorial/nodejsapp:master

Illustrative execution of Docker commands

Page 166: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

79

Case Study 2: Connect to the NodeJs App

Page 167: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

79

Case Study 2: Connect to the NodeJs App

Page 168: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

79

Case Study 2: Connect to the NodeJs App

docker-machine ls

Illustrative execution of Docker commands

Page 169: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

79

Case Study 2: Connect to the NodeJs App

docker-machine ls

Illustrative execution of Docker commands

Better solution (in Beta): https://beta.docker.com

Page 170: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

80

Case Study 2: Server-side Fix (live)

docker exec -ti nodejsapp bash

Illustrative execution of commands

Context

app/routes.js

Bug: the App. creates the same item twice

docker restart nodejsapp

apt-get update && apt-get install -y vimvim routers.js \ exit

Page 171: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

81

Docker in Continuous Integration and Delivery

Live Fix

CI

CD+

+

Page 172: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

81

Docker in Continuous Integration and Delivery

Local Build

ImageLive Fix

CI

CD+

+

Page 173: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

81

Docker in Continuous Integration and Delivery

Local Build

ImageLive Fix

CI

CD+

+

Docker Hub Build

Page 174: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Push

81

Docker in Continuous Integration and Delivery

Local Build

ImageLive Fix

CI

CD+

+

Docker Hub Build

Page 175: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Push

81

Docker in Continuous Integration and Delivery

Local Build

ImageLive Fix

CI

CD+

+

Docker Hub Build

Page 176: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

82

Case Study 2: Client-side Fix (new build)

docker build -t icwe2016dockertutorial/nodejsapp:master .

Illustrative execution of commands (cd NodeJSApp)

Context

public/js/controllers/main.js

Bug: the App. creates empty todos

docker run -d --net icwe2016 -p 8080:3000 --name nodejsapp icwe2016dockertutorial/nodejsapp:master

docker rm -f -v nodejsapp

Page 177: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

83

Case Study 2: Undeploy the App

docker rm -f —v mongodb redis nodejsappIllustrative execution of Docker commands

Page 178: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

84

Case Study 2: A Better Way of Starting the NodeJS App

Docker Compose

Page 179: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

85

Docker ComposeA tool for defining and running multi-container Docker applications

version: '2'

build:

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

volumes:

Page 180: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

85

Docker ComposeA tool for defining and running multi-container Docker applications

version: '2'

build:

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

volumes:

Build settings

Page 181: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

85

Docker ComposeA tool for defining and running multi-container Docker applications

version: '2'

build:

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

volumes:

Build settings

Services’ deployment settings

Page 182: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

85

Docker ComposeA tool for defining and running multi-container Docker applications

version: '2'

build:

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

volumes:

Build settings

Services’ deployment settings

Networks’ settings

Page 183: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

85

Docker ComposeA tool for defining and running multi-container Docker applications

version: '2'

build:

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

volumes:

Build settings

Services’ deployment settings

Networks’ settings

Volumes’ settings

Page 184: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

86

Docker ComposeA tool for defining and running multi-container Docker applications

docker-compose up -d

docker-compose start MongoDB

docker-compose logs

https://docs.docker.com/compose/reference/Many more possibilities, see full reference here:

Page 185: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

86

Docker ComposeA tool for defining and running multi-container Docker applications

docker-compose up -dStarts the services and detaches from the command

docker-compose start MongoDB

docker-compose logs

https://docs.docker.com/compose/reference/Many more possibilities, see full reference here:

Page 186: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

86

Docker ComposeA tool for defining and running multi-container Docker applications

docker-compose up -dStarts the services and detaches from the command

docker-compose start MongoDBStarts the MongoDB service

docker-compose logs

https://docs.docker.com/compose/reference/Many more possibilities, see full reference here:

Page 187: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

86

Docker ComposeA tool for defining and running multi-container Docker applications

docker-compose up -dStarts the services and detaches from the command

docker-compose start MongoDBStarts the MongoDB service

docker-compose logsShows the aggregated logs from all the services

https://docs.docker.com/compose/reference/Many more possibilities, see full reference here:

Page 188: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

87

Case Study 2: Docker Compose File (1/4)

version: '2'

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

Context

cd NodeJSApp

Page 189: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

87

Case Study 2: Docker Compose File (1/4)

version: '2'

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

Services’ deployment settings

Context

cd NodeJSApp

Page 190: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

87

Case Study 2: Docker Compose File (1/4)

version: '2'

services: mongodb: ...

redis: ...

nodejsapp: ...

networks: icwe2016: driver: bridge

Services’ deployment settings

Networks’ settings

Context

cd NodeJSApp

Page 191: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

88

Case Study 2: Docker Compose File (2/4)

services: mongodb: image: icwe2016dockertutorial/mongodb:master container_name: mongodb # make it explicit the ports exposed by the Dockefile expose: - 27017 # make it explicit the volumes exposed by the Dockerfile volumes: - /data/db - /data/configdb networks: - icwe2016

Page 192: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

89

Case Study 2: Docker Compose File (3/4)

redis: image: redis:3.2.0-alpine container_name: redis # make it explicit the ports exposed by the Dockefile expose: - 6379 # make it explicit the volumes exposed by the Dockerfile volumes: - /data networks: - icwe2016

Page 193: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

90

Case Study 2: Docker Compose File (4/4)

nodejsapp: image: icwe2016dockertutorial/nodejsapp:master container_name: nodejsapp # make it explicit the ports exposed by the Dockefile expose: - 3000 depends_on: - mongodb - redis ports: - "8080:3000" networks: - icwe2016

Page 194: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

91

Case Study 2: Starting the NodeJS App with Docker Compose

docker-compose up -dStarts the services and detaches from the command

docker-compose logs -fShows and follows the aggregated logs from all the services

Illustrative execution of Docker commands

Context

cd NodeJSApp

Page 195: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

92

Recap: Multi Containers Deployment

Page 196: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

92

Recap: Multi Containers Deployment> There are many images on the Docker Hub which we can reuse

Page 197: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

92

Recap: Multi Containers Deployment> There are many images on the Docker Hub which we can reuse

> Docker simplifies the reproducibility of bugs because we can always refer to the image built for a specific version

Page 198: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

92

Recap: Multi Containers Deployment> There are many images on the Docker Hub which we can reuse

> Docker simplifies the reproducibility of bugs because we can always refer to the image built for a specific version

> Docker speeds up the debugging of applications composed of many services

Page 199: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

92

Recap: Multi Containers Deployment> There are many images on the Docker Hub which we can reuse

> Docker simplifies the reproducibility of bugs because we can always refer to the image built for a specific version

> Docker speeds up the debugging of applications composed of many services

> Docker provides network abstraction for portable deployments of multi container services

Page 200: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

92

Recap: Multi Containers Deployment> There are many images on the Docker Hub which we can reuse

> Docker simplifies the reproducibility of bugs because we can always refer to the image built for a specific version

> Docker speeds up the debugging of applications composed of many services

> Docker provides network abstraction for portable deployments of multi container services

> Docker Compose enables portable deployment descriptors

Page 201: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

ICWE 2016, Lugano

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

End of Part III - Summary Time!

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

Page 202: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

94

Steps for ReproducibilityA recipe for enhancing reproducibility with Docker

Page 203: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

94

Steps for ReproducibilityA recipe for enhancing reproducibility with Docker

> Provide the source code (documented) on a public repository

Page 204: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

94

Steps for ReproducibilityA recipe for enhancing reproducibility with Docker

> Provide the source code (documented) on a public repository

> Release the Dockerfiles using version pinning

Page 205: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

94

Steps for ReproducibilityA recipe for enhancing reproducibility with Docker

> Provide the source code (documented) on a public repository

> Release the Dockerfiles using version pinning

> Setup an automated/trusted build on the Docker Hub

Page 206: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

94

Steps for ReproducibilityA recipe for enhancing reproducibility with Docker

> Provide the source code (documented) on a public repository

> Release the Dockerfiles using version pinning

> Setup an automated/trusted build on the Docker Hub

> Provide portable deployment descriptors using Docker Compose

Page 207: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

95

Steps for ReproducibilityAdditional useful services

> DOI for Source Code and Docker Images:

• Citable Codehttps://guides.github.com/activities/citable-code/

Page 208: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

95

Steps for ReproducibilityAdditional useful services

> DOI for Source Code and Docker Images:

• Citable Codehttps://guides.github.com/activities/citable-code/

• Citable Docker Images http://www.software.ac.uk/blog/2016-03-29-reproducible-research-citing-your-execution-environment-using-docker-and-doi

Page 209: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

96

Docker’s Limitations

Page 210: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

96

Docker’s Limitations

> Not enough for performance experiments [Jimenez et al., The Role of Container Technology in Reproducible Computer Systems Research]

Page 211: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

96

Docker’s Limitations

> Not enough for performance experiments [Jimenez et al., The Role of Container Technology in Reproducible Computer Systems Research]

> Not enough for data-intensive workload[http://ivory.idyll.org/blog/2015-docker-and-replicating-papers.html, data on http://www.zenodo.org]

Page 212: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

96

Docker’s Limitations

> Not enough for performance experiments [Jimenez et al., The Role of Container Technology in Reproducible Computer Systems Research]

> Not enough for data-intensive workload[http://ivory.idyll.org/blog/2015-docker-and-replicating-papers.html, data on http://www.zenodo.org]

> Limits with proprietary software and dependencies

Page 213: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

96

Docker’s Limitations

> Not enough for performance experiments [Jimenez et al., The Role of Container Technology in Reproducible Computer Systems Research]

> Not enough for data-intensive workload[http://ivory.idyll.org/blog/2015-docker-and-replicating-papers.html, data on http://www.zenodo.org]

> Limits with proprietary software and dependencies

> Non-Disclosure Agreements / Intellectual Property

Page 214: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

96

Docker’s Limitations

> Not enough for performance experiments [Jimenez et al., The Role of Container Technology in Reproducible Computer Systems Research]

> Not enough for data-intensive workload[http://ivory.idyll.org/blog/2015-docker-and-replicating-papers.html, data on http://www.zenodo.org]

> Limits with proprietary software and dependencies

> Non-Disclosure Agreements / Intellectual Property

> Can we build the same artifact from the specification (Dockerfile) even in 10 years? [Suggestion: Version Pinning]

Page 215: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Sum up and Conclusion

> Containers enable a standard, fast, and easy way of describing experiments and environments

> Containers help your future self, reviewers, and other researchers and colleagues to make use and improve your work

Page 216: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

98

Further Reading> Docker for beginners: http://prakhar.me/docker-curriculum/

> Docker Hands-on: https://github.com/alexellis/HandsOnDocker/blob/master/Labs.md

> Experience in using Docker for reproducible research: http://melissagymrek.com/science/2014/08/29/docker-reproducible-research.html

> Multi-host networking with Docker: https://docs.docker.com/engine/userguide/networking/get-started-overlay/

Page 217: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

ICWE 2016, Lugano

Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW

Question Time!

Jürgen Cito, Vincenzo Ferme, Harald C. Gall

Page 218: Using Docker Containers to Improve Reproducibility in Software and Web Engineering

Material: https://github.com/ICWE2016DockerTutorial https://hub.docker.com/u/icwe2016dockertutorial/

Speakers References + Slides + Material

Slides: http://icwe2016.inf.usi.ch/program/tutorials/docker

Vincenzo Ferme PhD @ [email protected]@VincenzoFerme

Jürgen Cito PhD @ UZH

[email protected]@citostyle