Upload
jfays
View
160
Download
0
Tags:
Embed Size (px)
Citation preview
Faculty of Applied SciencesSchool 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 2/30
Faculty of Applied SciencesSchool of engineering and computer science
Cytomine Team
Raphael Maree
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 3/30
Faculty of Applied SciencesSchool of engineering and computer science
Cytomine Team
Raphael Maree
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 3/30
Faculty of Applied SciencesSchool of engineering and computer science
Cytomine Team
Raphael Maree
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 3/30
Faculty of Applied SciencesSchool of engineering and computer science
Cytomine Team
Raphael Maree
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 3/30
Faculty of Applied SciencesSchool of engineering and computer science
Cytomine Team
Raphael Maree
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 3/30
Faculty of Applied SciencesSchool of engineering and computer science
Cytomine Team
Raphael Maree
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 3/30
Faculty of Applied SciencesSchool of engineering and computer science
A pleasure to use
CYTOMINE Install/Deploy
CYTOMINE Web ClientsCYTOMINE Clients
Backbone.jsHtml 5 Javascript AngularJS
JavaPython
Content based Image retrieval
CYTOMINE Retrieval
CYTOMINE Core
CYTOMINE Ims
REST API HTTP
Object DetectionCell ClassifierTissue Detect
Tissue SegmentAnnotation Stats
Your app…
CYTOMINE Apps
Redis Java
Grails Java Hibernate
PostgreSQL MongoDBPostgis
Grails Java
CYTOMINE IIP
CYTOMINE Monitoring
Node.js
MongoDB
File systemGlusterFS
Docker
CytomineA rich internet application
for visualization, collaborative annotation, and automatic analysis of large-scale bioimages
www.cytomine.be
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 4/30
Faculty of Applied SciencesSchool of engineering and computer science
... a HUGE mess to deploy
All these technologies used in the following developmentenvironments :
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 5/30
Faculty of Applied SciencesSchool of engineering and computer science
... a HUGE mess to deploy
All these technologies used in the following developmentenvironments :
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 5/30
Faculty of Applied SciencesSchool of engineering and computer science
... a HUGE mess to deploy
All these technologies used in the following developmentenvironments :
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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 5/30
Faculty of Applied SciencesSchool of engineering and computer science
What is Docker
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 6/30
Faculty of Applied SciencesSchool of engineering and computer science
What is Docker
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 6/30
Faculty of Applied SciencesSchool of engineering and computer science
What is Docker
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 7/30
Faculty of Applied SciencesSchool of engineering and computer science
What is DockerBy Wikipedia
Docker is an open-source project that automates the deploymentof applications inside software containers (...) on Linux.Docker uses resource isolation features of the Linux kernel such ascgroups and kernel namespaces to allow independent ”containers”to run within a single Linux instance.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 8/30
Faculty of Applied SciencesSchool of engineering and computer science
What is DockerBy Wikipedia
Docker is an open-source project that automates thedeployment of applications inside software containers (...) onLinux.Docker uses resource isolation features of the Linux kernel such ascgroups and kernel namespaces to allow independent”containers” to run within a single Linux instance.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 9/30
Faculty of Applied SciencesSchool of engineering and computer science
What Docker is notDifference to a VM
VM Docker
The processes are isolated from one another but not from the hostmachine.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 10/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useRun 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 11/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useRun 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 11/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useMain 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 12/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useMain 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 12/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useMain 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 12/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useMain 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 12/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useMain 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 12/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useMain 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 12/30
Faculty of Applied SciencesSchool of engineering and computer science
How to useExample
postgresql : -p 49153:5432
rails : -p 49154:3000 --link postgresql22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 13/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its container
I want my own custom container !
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 14/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerImage 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 thecommands you would normally execute manually in order tobuild a Docker image.
By calling docker build from your terminal, you can haveDocker build your image step by step, executing theinstructions successively.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 15/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerImage 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 thecommands you would normally execute manually in order tobuild a Docker image.
By calling docker build from your terminal, you can haveDocker build your image step by step, executing theinstructions successively.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 15/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerImage 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 thecommands you would normally execute manually in order tobuild a Docker image.
By calling docker build from your terminal, you can haveDocker build your image step by step, executing theinstructions successively.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 15/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerImage 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 thecommands you would normally execute manually in order tobuild a Docker image.
By calling docker build from your terminal, you can haveDocker build your image step by step, executing theinstructions successively.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 15/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerExample
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.shENTRYPOINT [”/entrypoint.sh”]
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 16/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerExample
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.shENTRYPOINT [”/entrypoint.sh”]
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 16/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerExample
cd redisTest && docker build -t="cytomine/redis" .
docker run -p 22 --privileged --name geekRedis \
-v .:/test/ cytomine/redis
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 17/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 18/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 18/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
First layer :
FROM debian:wheezyRUN 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 19/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
First layer :
FROM debian:wheezyRUN 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 19/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
First layer :
FROM debian:wheezyRUN 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 19/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
First layer :
FROM debian:wheezyRUN 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 19/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerLes oignons c’est bon
Step 0 : FROM ubuntu:14.04
---> 2103b00b3fdf
Step 1 : MAINTAINER Cytomine Team "[email protected]"
---> 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 20/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerInheritance
FROM redis
MAINTAINER ”Cytomine Team [email protected]”
...
RUN echo ”deb http://ppa.launchpad.net/webupd8team/java/ubuntu trustymain” | tee /etc/apt/sources.list .d/webupd8team−java.list
RUN apt−key adv −−keyserver hkp://keyserver.ubuntu.com:80 −−recv−keysEEA14886
RUN apt−get install −y oracle−java8−installer
ADD deploy.sh /tmp/deploy.shRUN chmod +x /tmp/deploy.sh
ENTRYPOINT [”/tmp/deploy.sh”]
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 21/30
Faculty of Applied SciencesSchool of engineering and computer science
Create its containerInheritance
FROM redis
MAINTAINER ”Cytomine Team [email protected]”
...
RUN echo ”deb http://ppa.launchpad.net/webupd8team/java/ubuntu trustymain” | tee /etc/apt/sources.list .d/webupd8team−java.list
RUN apt−key adv −−keyserver hkp://keyserver.ubuntu.com:80 −−recv−keysEEA14886
RUN apt−get install −y oracle−java8−installer
ADD deploy.sh /tmp/deploy.shRUN chmod +x /tmp/deploy.sh
ENTRYPOINT [”/tmp/deploy.sh”]
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 21/30
Faculty of Applied SciencesSchool of engineering and computer science
Advantages
Fig
Weave
DevOps
Because we love Open Source ;-)
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 22/30
Faculty of Applied SciencesSchool of engineering and computer science
AdvantagesFig
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 23/30
Faculty of Applied SciencesSchool 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 24/30
Faculty of Applied SciencesSchool of engineering and computer science
AdvantagesWeave
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 25/30
Faculty of Applied SciencesSchool of engineering and computer science
DrawbacksCache
Step 0 : FROM ubuntu:14.04
---> 2103b00b3fdf
Step 1 : MAINTAINER Cytomine Team "[email protected]"
---> 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 runanymore.
⇒ Bad surprise during a clean installation.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 26/30
Faculty of Applied SciencesSchool of engineering and computer science
DrawbacksCache
Step 0 : FROM ubuntu:14.04
---> 2103b00b3fdf
Step 1 : MAINTAINER Cytomine Team "[email protected]"
---> 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 runanymore.⇒ Bad surprise during a clean installation.
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 26/30
Faculty of Applied SciencesSchool of engineering and computer science
DrawbacksNo 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 27/30
Faculty of Applied SciencesSchool of engineering and computer science
DrawbacksNo 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 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 27/30
Faculty of Applied SciencesSchool of engineering and computer science
Docker used in productionCytomine Architecture
Diagram :
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 28/30
Faculty of Applied SciencesSchool of engineering and computer science
Devops
My dev’ environment
22 avril 2015 DockerRenaud Hoyoux - GIGA - Syst-Mod - Universite de Liege 29/30