2. Faculty of Applied Sciences
School of engineering and computer science
Program
Program :
What is Docker (and what Docker is not) ?
How to use it ?
How to create its own container ?
Advantages
Drawbacks
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 2/30
3. Faculty of Applied Sciences
School of engineering and computer science
Cytomine Team
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 3/30
4. Faculty of Applied Sciences
School of engineering and computer science
Cytomine Team
Rapha¨el Mar´ee
Group Leader
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 3/30
5. Faculty of Applied Sciences
School of engineering and computer science
Cytomine Team
Rapha¨el Mar´ee
Group Leader
Lo¨ıc Rollus
Lead Developer
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 3/30
6. Faculty of Applied Sciences
School of engineering and computer science
Cytomine Team
Rapha¨el Mar´ee
Group Leader
Lo¨ıc Rollus
Lead Developer
Renaud Hoyoux
Developer
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 3/30
7. Faculty of Applied Sciences
School of engineering and computer science
Cytomine Team
Rapha¨el Mar´ee
Group Leader
Lo¨ıc Rollus
Lead Developer
Renaud Hoyoux
Developer
Julien Confetti
Intern
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 3/30
8. Faculty of Applied Sciences
School of engineering and computer science
Cytomine Team
Rapha¨el Mar´ee
Group Leader
Lo¨ıc Rollus
Lead Developer
Renaud Hoyoux
Developer
Julien Confetti
Intern
Each of us has its speciality (Python, NodeJS, Groovy, Java8,
Frontend, RabbitMQ, ...).
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 3/30
9. Faculty of Applied Sciences
School of engineering and computer science
A pleasure to use
CYTOMINE Install/Deploy
CYTOMINE Web Clients
CYTOMINE Clients
Backbone.jsHtml 5 Javascript AngularJS
JavaPython
Content based
Image retrieval
CYTOMINE Retrieval
CYTOMINE Core
CYTOMINE Ims
REST API HTTP
Object Detection
Cell Classifier
Tissue Detect
Tissue Segment
Annotation Stats
Your app
…
CYTOMINE Apps
Redis Java
Grails Java Hibernate
PostgreSQL MongoDBPostgis
Grails Java
CYTOMINE IIP
CYTOMINE Monitoring
Node.js
MongoDB
File systemGlusterFS
Docker
Cytomine
A rich internet application
for visualization,
collaborative annotation,
and automatic analysis
of large-scale bioimages
www.cytomine.be
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 4/30
10. Faculty of Applied Sciences
School of engineering and computer science
... a HUGE mess to deploy
All these technologies used in the following development
environments :
Ubuntu 14.04 LTS
OSX
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 5/30
11. Faculty of Applied Sciences
School of engineering and computer science
... a HUGE mess to deploy
All these technologies used in the following development
environments :
Ubuntu 14.04 LTS
OSX
to deploy on these production environments :
Ubuntu 12.04 LTS
Ubuntu 14.04 LTS
Centos 6.6
Centos 7
?
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 5/30
12. Faculty of Applied Sciences
School of engineering and computer science
... a HUGE mess to deploy
All these technologies used in the following development
environments :
Ubuntu 14.04 LTS
OSX
to deploy on these production environments :
Ubuntu 12.04 LTS
Ubuntu 14.04 LTS
Centos 6.6
Centos 7
?
⇒ WARNING ! ! ! Problems are coming !
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 5/30
13. Faculty of Applied Sciences
School of engineering and computer science
What is Docker
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 6/30
14. Faculty of Applied Sciences
School of engineering and computer science
What is Docker
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 6/30
15. Faculty of Applied Sciences
School of engineering and computer science
What is Docker
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 7/30
16. Faculty of Applied Sciences
School of engineering and computer science
What is Docker
By Wikipedia
Docker is an open-source project that automates the deployment
of applications inside software containers (...) on Linux.
Docker uses resource isolation features of the Linux kernel such as
cgroups and kernel namespaces to allow independent ”containers”
to run within a single Linux instance.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 8/30
17. Faculty of Applied Sciences
School of engineering and computer science
What is Docker
By Wikipedia
Docker is an open-source project that automates the
deployment of applications inside software containers (...) on
Linux.
Docker uses resource isolation features of the Linux kernel such as
cgroups and kernel namespaces to allow independent
”containers” to run within a single Linux instance.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 9/30
18. Faculty of Applied Sciences
School of engineering and computer science
What Docker is not
Diff´erence to a VM
VM Docker
The processes are isolated from one another but not from the host
machine.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 10/30
19. Faculty of Applied Sciences
School of engineering and computer science
How to use
Run a container
I want to try centos
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 11/30
20. Faculty of Applied Sciences
School of engineering and computer science
How to use
Run a container
I want to try centos
sudo docker run centos
>> Unable to find image ’centos:latest’ locally
>> centos:latest: The image you are pulling has been
verified
>> 88f9454e60dd: Pull complete
>> 511136ea3c5a: Already exists
>> 5b12ef8fd570: Already exists sudo docker run -it
centos /bin/bash
>> Status: Downloaded newer image for centos:latest
>> FATA[0000] Error response from daemon: No command
specified
sudo docker run centos /bin/bash
sudo docker run -t centos /bin/bash
[root@15a1a295ae56 /]#
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 11/30
21. Faculty of Applied Sciences
School of engineering and computer science
How to use
Main commands
-v path:path Volumes mapping
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 12/30
22. Faculty of Applied Sciences
School of engineering and computer science
How to use
Main commands
-v path:path Volumes mapping
-p port:port Ports binding
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 12/30
23. Faculty of Applied Sciences
School of engineering and computer science
How to use
Main commands
-v path:path Volumes mapping
-p port:port Ports binding
--link One way communication
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 12/30
24. Faculty of Applied Sciences
School of engineering and computer science
How to use
Main commands
-v path:path Volumes mapping
-p port:port Ports binding
--link One way communication
-e Set an environment variable
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 12/30
25. Faculty of Applied Sciences
School of engineering and computer science
How to use
Main commands
-v path:path Volumes mapping
-p port:port Ports binding
--link One way communication
-e Set an environment variable
--name Set name
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 12/30
26. Faculty of Applied Sciences
School of engineering and computer science
How to use
Main commands
-v path:path Volumes mapping
-p port:port Ports binding
--link One way communication
-e Set an environment variable
--name Set name
--privileged
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 12/30
27. Faculty of Applied Sciences
School of engineering and computer science
How to use
Example
postgresql : -p 49153:5432
rails : -p 49154:3000 --link postgresql
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 13/30
28. Faculty of Applied Sciences
School of engineering and computer science
Create its container
I want my own custom container !
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 14/30
29. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Image and Dockerfile
An image is a read-only layer.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 15/30
30. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Image and Dockerfile
An image is a read-only layer.
We run container based on an image.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 15/30
31. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Image and Dockerfile
An image is a read-only layer.
We run container based on an image.
A Dockerfile is a text document that contains all the
commands you would normally execute manually in order to
build a Docker image.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 15/30
32. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Image and Dockerfile
An image is a read-only layer.
We run container based on an image.
A Dockerfile is a text document that contains all the
commands you would normally execute manually in order to
build a Docker image.
By calling docker build from your terminal, you can have
Docker build your image step by step, executing the
instructions successively.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 15/30
33. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Example
Redis installation
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 16/30
34. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Example
Redis installation
FROM debian:wheezy
RUN apt−get update && apt−get install −y curl
&& rm −rf /var/lib/apt/ lists /∗
RUN curl −o /usr/local/bin/gosu −SL
”https://github.com/tianon/gosu/releases/download/1.2/gosu−$(dpkg
−−print−architecture)”
&& gpg −−verify /usr/local/bin/gosu.asc && rm /usr/local/bin/gosu.asc
&& chmod +x /usr/local/bin/gosu
ENV REDIS VERSION 2.8.19
ADD docker−entrypoint.sh /entrypoint.sh
ENTRYPOINT [”/entrypoint.sh”]
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 16/30
35. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Example
cd redisTest && docker build -t="cytomine/redis" .
docker run -p 22 --privileged --name geekRedis
-v .:/test/ cytomine/redis
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 17/30
36. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 18/30
37. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 18/30
38. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
First layer :
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 19/30
39. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
First layer :
FROM debian:wheezy
RUN apt−get update && apt−get install −y curl
&& rm −rf /var/lib/apt/ lists /∗
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 19/30
40. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
First layer :
FROM debian:wheezy
RUN apt−get update && apt−get install −y curl
&& rm −rf /var/lib/apt/ lists /∗
Second layer :
RUN curl −o /usr/local/bin/gosu −SL
”https://github.com/tianon/gosu/releases/download/1.2/gosu−$(dpkg
−−print−architecture)”
&& gpg −−verify /usr/local/bin/gosu.asc && rm /usr/local/bin/gosu.asc
&& chmod +x /usr/local/bin/gosu
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 19/30
41. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
First layer :
FROM debian:wheezy
RUN apt−get update && apt−get install −y curl
&& rm −rf /var/lib/apt/ lists /∗
Second layer :
RUN curl −o /usr/local/bin/gosu −SL
”https://github.com/tianon/gosu/releases/download/1.2/gosu−$(dpkg
−−print−architecture)”
&& gpg −−verify /usr/local/bin/gosu.asc && rm /usr/local/bin/gosu.asc
&& chmod +x /usr/local/bin/gosu
Third layer :
ENV REDIS VERSION 2.8.19
...
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 19/30
42. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Les oignons c’est bon
Step 0 : FROM ubuntu:14.04
---> 2103b00b3fdf
Step 1 : MAINTAINER Cytomine Team "support@cytomine.be"
---> Using cache
---> c544207d0347
Step 2 : RUN apt-get install -y openssh-server
---> Using cache
---> e4cefcd52418
...
Step 9 : EXPOSE 22
---> Using cache
---> 3e0d97b94f3e
Successfully built 3e0d97b94f3e
Sending build context to Docker daemon 9.728 kB
Sending build context to Docker daemon
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 20/30
43. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Inheritance
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 21/30
44. Faculty of Applied Sciences
School of engineering and computer science
Create its container
Inheritance
FROM redis
MAINTAINER ”Cytomine Team support@cytomine.be”
...
RUN echo ”deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty
main” | tee /etc/apt/sources.list .d/webupd8team−java.list
RUN apt−key adv −−keyserver hkp://keyserver.ubuntu.com:80 −−recv−keys
EEA14886
RUN apt−get install −y oracle−java8−installer
ADD deploy.sh /tmp/deploy.sh
RUN chmod +x /tmp/deploy.sh
ENTRYPOINT [”/tmp/deploy.sh”]
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 21/30
45. Faculty of Applied Sciences
School of engineering and computer science
Advantages
Fig
Weave
DevOps
Because we love Open Source ;-)
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 22/30
46. Faculty of Applied Sciences
School of engineering and computer science
Advantages
Fig
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 23/30
47. Faculty of Applied Sciences
School of engineering and computer science
Advantages
Before
docker run -d redis
docker build -t="web" .
docker run -d -p 5000:5000
--link redis:redis
-v .:/code --name web
web
After
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
links:
- redis
redis:
image: redis
So long fig ! Welcome to Docker Compose !
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 24/30
48. Faculty of Applied Sciences
School of engineering and computer science
Advantages
Weave
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 25/30
49. Faculty of Applied Sciences
School of engineering and computer science
Drawbacks
Cache
Step 0 : FROM ubuntu:14.04
---> 2103b00b3fdf
Step 1 : MAINTAINER Cytomine Team "support@cytomine.be"
---> Using cache
---> c544207d0347
Step 2 : RUN apt-get install -y openssh-server
---> Using cache
---> e4cefcd52418
...
The cache is used even if the above command doesn’t run
anymore.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 26/30
50. Faculty of Applied Sciences
School of engineering and computer science
Drawbacks
Cache
Step 0 : FROM ubuntu:14.04
---> 2103b00b3fdf
Step 1 : MAINTAINER Cytomine Team "support@cytomine.be"
---> Using cache
---> c544207d0347
Step 2 : RUN apt-get install -y openssh-server
---> Using cache
---> e4cefcd52418
...
The cache is used even if the above command doesn’t run
anymore.
⇒ Bad surprise during a clean installation.
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 26/30
51. Faculty of Applied Sciences
School of engineering and computer science
Drawbacks
No dynamic container linking
if [ $APP1_ENABLED = true ]
then
docker run --link app1
... (plenty lines)
else if [ $APP2_ENABLED = true ]
then
docker run --link app2
... (plenty lines)
else
...
fi
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 27/30
52. Faculty of Applied Sciences
School of engineering and computer science
Drawbacks
No dynamic container linking
if [ $APP1_ENABLED = true ]
then
docker run --link app1
... (plenty lines)
else if [ $APP2_ENABLED = true ]
then
docker run --link app2
... (plenty lines)
else
...
fi
:s
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 27/30
53. Faculty of Applied Sciences
School of engineering and computer science
Docker used in production
Cytomine Architecture
Diagram :
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 28/30
54. Faculty of Applied Sciences
School of engineering and computer science
Devops
My dev’ environment
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 29/30
55. Faculty of Applied Sciences
School of engineering and computer science
The end
Thanks !
22 avril 2015 Docker
Renaud Hoyoux - GIGA - Syst-Mod - Universit´e de Li`ege 30/30