The ability to replicate and reproduce scientific results has become an increasingly important topic for many academic disciplines. In computer science and, more specifically, software and Web engineering, contributions of scientific work rely on developed algorithms, tools and prototypes, quantitative evaluations, and other computational analyses. Published code and data come with many undocumented assumptions, dependencies, and configurations that are internal knowledge and make reproducibility hard to achieve. This tutorial presents how Docker containers can overcome these issues and aid the reproducibility of research artefacts in software engineering and discusses their applications in the field.
Cite us: http://link.springer.com/chapter/10.1007/978-3-319-38791-8_58
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Using Docker Containers to Improve Reproducibility in Software and Web Engineering
1. 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
5. 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)
6. 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)
7. 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
8. 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 considered
to be the final word, and the replication
and corroboration of research results is key
to the scientific process.
9. 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.”
12. 9
What is Reproducibility?
Establishing facts
> Steps (or a method) to establish the fact
> Sharing computational knowledge
Controlling environment
> Execution environment
> Dependencies
13. 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
14. 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
15. 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
16. 11
In Software Engineering Research:
- FSE’15/16, MSR’15/16
In Programming Languages Research:
- PLDI, POPL, OOPSLA
Artifact Evaluation & Replication Packages
18. 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
19. 14
Case Study 1: ChangeDistiller
https://bitbucket.org/sealuzh/tools-changedistiller
Research Project
21. 16
Reasons for Failed Reproducibility (1/2)
*https://twitter.com/ianholmes/status/288689712636493824
22. 17Source: Collberg et al., “Measuring Reproducibility in Computer Systems Research”, http://reproducibility.cs.arizona.edu/tr.pdf
Reasons for Failed Reproducibility (2/2)
23. 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?
25. 19
> No standard way of describing experiments,
environments, (derived) data, and workflows
Challenges in Reproducibility
26. 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
27. 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
28. 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
29. 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
31. 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
32. 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
33. 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/
34. 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
35. 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
36. 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 technologies
37. 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
38. 27
Dockerfile
Declarative definition of an environment for producing an image
Docker Image
Immutable artifact built from a Dockerfile, has one to many layers
Docker Container
Execution environment - Instantiation/running version of an image (can be
parameterized)
Docker Machine
Creates Docker hosts on your local Mac or Windows box
Docker Registry
Public or private repository stores images and allows for their distribution
(Docker Hub - https://hub.docker.com/ or CoreOS Quay - https://quay.io/)
Terminology
39. 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
40. 29
Dockerfile
Defines 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"]
41. 29
Dockerfile
Defines 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
42. 29
Dockerfile
Defines 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
Base Image can be an OS (Ubuntu)
or a different, existing image
43. 29
Dockerfile
Defines 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
Base Image can be an OS (Ubuntu)
or a different, existing image
44. 29
Dockerfile
Defines 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
Base Image can be an OS (Ubuntu)
or a different, existing image
Runs commands as if you were typing
them in the command line
45. 29
Dockerfile
Defines 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
46. 29
Dockerfile
Defines 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
47. 29
Dockerfile
Defines 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
48. 29
Dockerfile
Defines 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
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
49. 29
Dockerfile
Defines 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
50. 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/
51. 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
52. 32
Dockerfile —> Image
Defines the infrastructure and dependencies of a container through instructions
docker build -t <imagename> .
53. 32
Dockerfile —> Image
Defines the infrastructure and dependencies of a container through instructions
docker build -t <imagename> .
Build Context
containing all local
dependencies and
Dockerfile
54. 33
Docker Images
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mhart/alpine-node latest 2a15d8568f75 1 week ago 36.76 MB
hakyll latest d575da1e730c 2 weeks ago 1.487 GB
redis alpine 50405530a7e5 4 weeks ago 15.95 MB
# docker rmi hakyll
Untagged: hakyll:latest
Deleted: sha256:3240943c9ea3f72db51…
Deleted: sha256:a3aeefae0d4b8f61…
Deleted: sha256:16a7ebd378002f1261…
55. 33
Docker Images
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mhart/alpine-node latest 2a15d8568f75 1 week ago 36.76 MB
hakyll latest d575da1e730c 2 weeks ago 1.487 GB
redis alpine 50405530a7e5 4 weeks ago 15.95 MB
# docker rmi hakyll
Untagged: hakyll:latest
Deleted: sha256:3240943c9ea3f72db51…
Deleted: sha256:a3aeefae0d4b8f61…
Deleted: sha256:16a7ebd378002f1261…
Lists all previously built images
56. 33
Docker Images
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mhart/alpine-node latest 2a15d8568f75 1 week ago 36.76 MB
hakyll latest d575da1e730c 2 weeks ago 1.487 GB
redis alpine 50405530a7e5 4 weeks ago 15.95 MB
# docker rmi hakyll
Untagged: hakyll:latest
Deleted: 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
57. 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
58. 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)
59. 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)
60. 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)
61. 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 mapping
First the exposed port (80)
Second the port within the container (5000)
Many more possibilities to run containers, see full reference here:
(A typical example)
64. 36
Container Management
docker ps
Lists all running containers
docker ps -a
Lists all containers (including the ones that are stopped)
docker stop <container>
docker rm <container>
docker rm -v <container>
65. 36
Container Management
docker ps
Lists all running containers
docker ps -a
Lists all containers (including the ones that are stopped)
docker stop <container>
Stops a running container
docker rm <container>
docker rm -v <container>
66. 36
Container Management
docker ps
Lists all running containers
docker ps -a
Lists 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>
67. 36
Container Management
docker ps
Lists all running containers
docker ps -a
Lists 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
69. 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>
70. 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
71. 37
Container Debugging
docker run -ti --entrypoint=bash <imagename>
docker exec -ti <container> bash
Starts 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
72. 37
Container Debugging
docker run -ti --entrypoint=bash <imagename>
Starts a container with a different entrypoint
docker exec -ti <container> bash
Starts 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
78. 43
Pushing Docker Images to a Registry
Tag Image
docker tag c6fdd6639541 <username>/<imagename>:<tagname>
Image Id
(retrieve through )docker images
80. 44
Pushing Docker Images to a Registry
Push Image
docker login --username=<username> --email=<email>
81. 44
Pushing Docker Images to a Registry
Push Image
docker login --username=<username> --email=<email>
docker push <username>/<imagename>:<tagname>
82. 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
83. 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
84. 47
Case Study 1: ChangeDistiller
https://goo.gl/3h7DGA
We paste the commands we run, live at the following url:
85. 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"]
86. 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
87. 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
88. 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
89. 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
90. 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
91. 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
92. 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:master
Creates the container and runs the analysis
Context
cd ChangeDistiller
93. 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"]
94. 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
98. 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
99. 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
100. 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
101. 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
102. 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
103. ICWE 2016, Lugano
Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW
Question Time!
Jürgen Cito, Vincenzo Ferme, Harald C. Gall
104. 54
Part III - Multi Containers Docker Application
Preview
Reproduce Bugs present in a Version of a CRUD Web Application
54
Redis
NodeJS App
MongoDB
network
105. 54
Part III - Multi Containers Docker Application
Preview
Reproduce Bugs present in a Version of a CRUD Web Application
54
Redis
NodeJS App
link
MongoDB
link
network
106. 54
Part III - Multi Containers Docker Application
Preview
Reproduce Bugs present in a Version of a CRUD Web Application
54
Redis
NodeJS App
link
MongoDB
link
network
Docker Compose
107. 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
108. 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
111. 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
112. 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
113. 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
114. 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
115. 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
116. 59
Case Study 2: NodeJS + MongoDB + Redis
Reproduce Bugs present in a Version of a CRUD Web Application
Redis
NodeJS App
MongoDB
network
117. 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
118. 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
119. 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
120. 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
130. 63
Docker Networks
icwe2016
NodeJS App
docker run -d --net icwe2016 ... MongoDB
Starts 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:
131. 63
Docker Networks
icwe2016
NodeJS App
docker run -d --net icwe2016 ... MongoDB
Starts 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:
134. 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
135. 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
136. 66
Case Study 2: NodeJS + MongoDB + Redis
https://goo.gl/3h7DGA
We paste the commands we run, live at the following url:
137. 67
Case Study 2: Web Application
https://github.com/scotch-io/node-todoRepo with the Application we have started from:
138. 67
Case Study 2: Web Application
https://github.com/scotch-io/node-todoRepo with the Application we have started from:
139. 67
Case Study 2: Web Application
https://github.com/scotch-io/node-todoRepo with the Application we have started from:
140. 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
141. 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
142. 69
Case Study 2: NodeJS App
Relevant files for Docker
config/database.js
config/redis.js
bin/*
143. 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" ]
144. 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
145. 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
146. 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
147. 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.
148. 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
149. 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
150. 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
151. 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
152. 71
Case Study 2: NodeJS App
docker build -t icwe2016dockertutorial/
nodejsapp:master .
Illustrative execution of Docker commands
Context
cd NodeJSApp
153. 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
155. 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"]
156. 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
157. 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
158. 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
159. 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
160. 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
161. 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
162. 75
Case Study 2: MongoDB
docker build -t icwe2016dockertutorial/
mongodb:master .
Illustrative execution of Docker commands
Context
cd MongoDB
163. 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
168. 79
Case Study 2: Connect to the NodeJs App
docker-machine ls
Illustrative execution of Docker commands
169. 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
170. 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 vim
vim routers.js exit
184. 86
Docker Compose
A 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:
185. 86
Docker Compose
A tool for defining and running multi-container Docker applications
docker-compose up -d
Starts 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:
186. 86
Docker Compose
A tool for defining and running multi-container Docker applications
docker-compose up -d
Starts the services and detaches from the command
docker-compose start MongoDB
Starts the MongoDB service
docker-compose logs
https://docs.docker.com/compose/reference/
Many more possibilities, see full reference here:
187. 86
Docker Compose
A tool for defining and running multi-container Docker applications
docker-compose up -d
Starts the services and detaches from the command
docker-compose start MongoDB
Starts the MongoDB service
docker-compose logs
Shows the aggregated logs from all the services
https://docs.docker.com/compose/reference/
Many more possibilities, see full reference here:
188. 87
Case Study 2: Docker Compose File (1/4)
version: '2'
services:
mongodb:
...
redis:
...
nodejsapp:
...
networks:
icwe2016:
driver: bridge
Context
cd NodeJSApp
189. 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
190. 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
191. 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
192. 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
193. 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
194. 91
Case Study 2: Starting the NodeJS App
with Docker Compose
docker-compose up -d
Starts the services and detaches from the command
docker-compose logs -f
Shows and follows the aggregated logs from all the services
Illustrative execution of Docker commands
Context
cd NodeJSApp
197. 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
198. 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
199. 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
200. 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
201. 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
203. 94
Steps for Reproducibility
A recipe for enhancing reproducibility with Docker
> Provide the source code (documented) on a public
repository
204. 94
Steps for Reproducibility
A recipe for enhancing reproducibility with Docker
> Provide the source code (documented) on a public
repository
> Release the Dockerfiles using version pinning
205. 94
Steps for Reproducibility
A 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
206. 94
Steps for Reproducibility
A 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
207. 95
Steps for Reproducibility
Additional useful services
> DOI for Source Code and Docker Images:
• Citable Code
https://guides.github.com/activities/citable-code/
208. 95
Steps for Reproducibility
Additional useful services
> DOI for Source Code and Docker Images:
• Citable Code
https://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
210. 96
Docker’s Limitations
> Not enough for performance experiments
[Jimenez et al., The Role of Container Technology in Reproducible Computer Systems Research]
211. 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]
212. 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
213. 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
214. 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]
215. 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
216. 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/
217. ICWE 2016, Lugano
Photo Credits: Astrid Westvang, https://flic.kr/p/pWJLCW
Question Time!
Jürgen Cito, Vincenzo Ferme, Harald C. Gall