SlideShare a Scribd company logo
1 of 22
Download to read offline
Docker / Ansible



Stéphane Manciot
19/02/2015
Problem - the matrix from Hell
LXC - the intermodal shipping container
LXC - main features
○ Portability
○ run everywhere
○ regardless of kernel version
○ regardless of host distro
○ run anything
○ if it can run on the host, it can run in the
container
○ i.e., if it can run on a Linux kernel, it can run
○ Isolation (namespaces)
○ Control resources (cgroups)
○ Lightweight VM (own process space, own network
interface …) without performance penalty (no
device emulation)
DevOps - separation of concerns
○ Developer - Inside the container
○ my code
○ my libraries
○ my package manager
○ my app
○ my data
○ Operational - Outside the container
○ logging
○ remote access
○ network configuration
○ monitoring
Docker - main features
○ a single application virtualization engine based
on containers
○ a standard, reproductible way to easily build and
share trusted images (Dockerfile, Stackbrew,
docker-registry …)
○ each image is a stack of layers (1 layer = tarball
+ metadata)
○ a daemon running in the background
○ manages containers, images and builds
○ HTTP api (over UNIX or TCP socket)
○ embedded CLI talking to the api
LXC versus Docker
Docker - PaaS
○ Portability
○ Fast provisioning (Another Union File System)
○ Performance
○ processes are isolated, but run straight on the
host
○ CPU performance = native performance
○ almost native memory performance
○ network performance = small overhead
Docker - quick start
○ search an image : sudo docker search debian
○ list images : sudo docker images
○ download an image : sudo docker pull debian
○ run a container : sudo docker run [OPTIONS]
IMAGE[:TAG] [COMMAND] [ARGS…]
○ list all containers : sudo docker ps -a
○ find the id of the last launched container : sudo
docker ps -l
○ commit container updates : sudo docker commit
ID [IMAGE[:TAG]]
○ inspect a container : sudo docker inspect ID
○ upload an image : sudo docker push IMAGE
Exercise
○ create a docker image from the latest debian
image including oracle java7 as debian:oracle-
java7
○ http://www.webupd8.org/2012/06/how-to-install-
oracle-java-7-in-debian.html
Dockerfile
○ Usage : sudo docker build -t=“IMAGE[:TAG]” .
○ Format :
○ # Comment
○ INSTRUCTION arguments
○ FROM image[:TAG]
○ MAINTAINER <name>
○ RUN <command>
○ CMD [“executable","param1","param2"] | CMD
[“param1","param2"] | CMD command param1
param2
Dockerfile
○ EXPOSE <port> [<port>…]
○ ENV foo bar | ENV foo=bar
○ ADD <src>... <dest>
○ ADD hom* /mydir/
○ ADD hom?.txt /mydir/
○ ADD test aDir/
○ COPY <src>... <dest>
○ ENTRYPOINT ["executable", "param1",
“param2"]
○ VOLUME [“/data"]
○ WORKDIR /path/to/workdir
○ ONBUILD [INSTRUCTION]
Dockerfile - best practices
○ add a .dockerignore file
○ avoid installing unnecessary packages
○ run only one process per container
○ minimize the number of layers
○ put long or complex RUN statements on multiple
lines separated with backslashes
○ sort multi-line arguments
○ prefer COPY to ADD
○ use VOLUME for any mutable parts of your
image
Dockerfile - Examples
○ apache2
Dockerfile - Examples
Exercise
○ create a docker image from the latest debian
image including oracle java7 as dockerfile/
debian:oracle-java7 using Dockerfile
○ http://www.webupd8.org/2012/06/how-to-install-
oracle-java-7-in-debian.html
Docker - overriding image defaults
○ CMD
○ sudo docker run [OPTIONS] IMAGE[:TAG]
[COMMAND] [ARGS...]
○ ENTRYPOINT
○ sudo docker run -i -t --entrypoint /bin/bash
example/redis
○ EXPOSE (incoming ports)
○ --expose=[]: Expose a port or a range of ports
from the container without binding
○ -P : bind the exposed ports to a random port
on the host between 49153 and 65535
○ -p [ip:][hostPort:]containerPort
○ --link <name or id container>:alias
Docker - overriding image defaults
○ ENV
○ sudo docker run -e "deep=purple" --rm
ubuntu /bin/bash -c export
○ VOLUME
○ -v=[]: Create a bind mount with: [host-dir]:
[container-dir]:[rw|ro]
○ --volumes-from CONTAINER : share volumes
with another container
○ USER
○ -u="": Username or UID
○ WORKDIR
○ -w="": Working directory inside the container
Docker - ambassador pattern
(consumer) --> (es_http_client)
---network--->
(es_ambassador) --> (es)
○ vagrant ssh mogobiz-db
○ sudo docker run -d --name es -P --volumes-from elasticsearch mogobiz/
elasticsearch-1.3.6
○ sudo docker run -d --link es:es --name es_ambassador -p
192.168.56.110:19200:9200 -p 192.168.56.110:19300:9300 svendowideit/
ambassador
○ vagrant ssh mogobiz-web
○ sudo docker run -d --name es_http_client --expose 9200 -e
ELASTICSEARCH_PORT_9200_TCP=tcp://192.168.56.110:19200
svendowideit/ambassador
○ sudo docker run -t -i --rm --link es_http_client:elasticsearch --link
mogobiz_db_client:mogobiz_db --name consumer -p 8080 busybox sh
○ / # env
Ansible and docker
○ Build new image
○ Run a container
Vagrant and Ansible
Vagrant and Ansible

More Related Content

What's hot

Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 

What's hot (20)

Intro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and WindowsIntro- Docker Native for OSX and Windows
Intro- Docker Native for OSX and Windows
 
From zero to Docker
From zero to DockerFrom zero to Docker
From zero to Docker
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
 
When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia
When Docker ends, Chef begins ~ #idi2015 Incontro DevOps ItaliaWhen Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia
When Docker ends, Chef begins ~ #idi2015 Incontro DevOps Italia
 
Docker 1.11 @ Docker SF Meetup
Docker 1.11 @ Docker SF MeetupDocker 1.11 @ Docker SF Meetup
Docker 1.11 @ Docker SF Meetup
 
JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...
JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...
JavaCro'15 - Docker, Kubernetes and Jube - a new cloud architecture - Aleš Ju...
 
Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1Academy PRO: Docker. Part 1
Academy PRO: Docker. Part 1
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4
 
Docker 101 - from 0 to Docker in 30 minutes
Docker 101 - from 0 to Docker in 30 minutesDocker 101 - from 0 to Docker in 30 minutes
Docker 101 - from 0 to Docker in 30 minutes
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker compose
Docker composeDocker compose
Docker compose
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
 
Containers: What are they, Really?
Containers: What are they, Really?Containers: What are they, Really?
Containers: What are they, Really?
 
Fabric8 CI/CD
Fabric8 CI/CDFabric8 CI/CD
Fabric8 CI/CD
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
[Szjug] Docker. Does it matter for java developer?
[Szjug] Docker. Does it matter for java developer?[Szjug] Docker. Does it matter for java developer?
[Szjug] Docker. Does it matter for java developer?
 
Docker at Flux7
Docker at Flux7Docker at Flux7
Docker at Flux7
 

Viewers also liked

Continuous integration with Docker and Ansible
Continuous integration with Docker and AnsibleContinuous integration with Docker and Ansible
Continuous integration with Docker and Ansible
Dmytro Slupytskyi
 

Viewers also liked (15)

Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
 
DevOps
DevOpsDevOps
DevOps
 
Mind the Gap: Crossing the DevOps Chasm
Mind the Gap: Crossing the DevOps ChasmMind the Gap: Crossing the DevOps Chasm
Mind the Gap: Crossing the DevOps Chasm
 
Elastic jenkins with mesos and dcos (2016 01-20)
Elastic jenkins with mesos and dcos (2016 01-20)Elastic jenkins with mesos and dcos (2016 01-20)
Elastic jenkins with mesos and dcos (2016 01-20)
 
TIAD 2016 : Test driven infrastructure with Ansible - Docker - Jenkins
TIAD 2016 : Test driven infrastructure with Ansible - Docker - JenkinsTIAD 2016 : Test driven infrastructure with Ansible - Docker - Jenkins
TIAD 2016 : Test driven infrastructure with Ansible - Docker - Jenkins
 
Vagrant + Ansible + Docker
Vagrant + Ansible + DockerVagrant + Ansible + Docker
Vagrant + Ansible + Docker
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with Ansible
 
Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Vagrant, Ansible and Docker - How they fit together for productive flexible d...Vagrant, Ansible and Docker - How they fit together for productive flexible d...
Vagrant, Ansible and Docker - How they fit together for productive flexible d...
 
Continuous integration with Docker and Ansible
Continuous integration with Docker and AnsibleContinuous integration with Docker and Ansible
Continuous integration with Docker and Ansible
 
Ansible Oxford - Cows & Containers
Ansible Oxford - Cows & ContainersAnsible Oxford - Cows & Containers
Ansible Oxford - Cows & Containers
 
CI/CD with Docker, DC/OS, and Jenkins
CI/CD with Docker, DC/OS, and JenkinsCI/CD with Docker, DC/OS, and Jenkins
CI/CD with Docker, DC/OS, and Jenkins
 
HP Advanced Technology Group: Docker and Ansible
HP Advanced Technology Group: Docker and AnsibleHP Advanced Technology Group: Docker and Ansible
HP Advanced Technology Group: Docker and Ansible
 
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
 
DevOps: A Culture Transformation, More than Technology
DevOps: A Culture Transformation, More than TechnologyDevOps: A Culture Transformation, More than Technology
DevOps: A Culture Transformation, More than Technology
 
Introducing DevOps
Introducing DevOpsIntroducing DevOps
Introducing DevOps
 

Similar to Docker / Ansible

Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
nigamsajal14
 

Similar to Docker / Ansible (20)

Start your container journey safely
Start your container journey safelyStart your container journey safely
Start your container journey safely
 
Containers + Docker workshop - part 2
Containers + Docker workshop - part 2Containers + Docker workshop - part 2
Containers + Docker workshop - part 2
 
Docker in a JS Developer’s Life
Docker in a JS Developer’s LifeDocker in a JS Developer’s Life
Docker in a JS Developer’s Life
 
Docker Up and Running Introduction
Docker Up and Running IntroductionDocker Up and Running Introduction
Docker Up and Running Introduction
 
Powercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptxPowercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptx
 
Data Science Workflows using Docker Containers
Data Science Workflows using Docker ContainersData Science Workflows using Docker Containers
Data Science Workflows using Docker Containers
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and Docker
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Clouds and Tools: Cheat Sheets & Infographics
Clouds and Tools: Cheat Sheets & InfographicsClouds and Tools: Cheat Sheets & Infographics
Clouds and Tools: Cheat Sheets & Infographics
 
DOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDESDOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDES
 
Docker.pdf
Docker.pdfDocker.pdf
Docker.pdf
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 
Docker slides
Docker slidesDocker slides
Docker slides
 
Docker
DockerDocker
Docker
 
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete MeetupIntroducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
 
Build and run applications in a dockerless kubernetes world
Build and run applications in a dockerless kubernetes worldBuild and run applications in a dockerless kubernetes world
Build and run applications in a dockerless kubernetes world
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
 

More from Stephane Manciot (6)

Des principes de la démarche DevOps à sa mise en oeuvre
Des principes de la démarche DevOps à sa mise en oeuvreDes principes de la démarche DevOps à sa mise en oeuvre
Des principes de la démarche DevOps à sa mise en oeuvre
 
Packaging et déploiement d'une application avec Docker et Ansible @DevoxxFR 2015
Packaging et déploiement d'une application avec Docker et Ansible @DevoxxFR 2015Packaging et déploiement d'une application avec Docker et Ansible @DevoxxFR 2015
Packaging et déploiement d'une application avec Docker et Ansible @DevoxxFR 2015
 
DevOps avec Ansible et Docker
DevOps avec Ansible et DockerDevOps avec Ansible et Docker
DevOps avec Ansible et Docker
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
De Maven à SBT ScalaIO 2013
De Maven à SBT ScalaIO 2013De Maven à SBT ScalaIO 2013
De Maven à SBT ScalaIO 2013
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Docker / Ansible

  • 2. Problem - the matrix from Hell
  • 3. LXC - the intermodal shipping container
  • 4. LXC - main features ○ Portability ○ run everywhere ○ regardless of kernel version ○ regardless of host distro ○ run anything ○ if it can run on the host, it can run in the container ○ i.e., if it can run on a Linux kernel, it can run ○ Isolation (namespaces) ○ Control resources (cgroups) ○ Lightweight VM (own process space, own network interface …) without performance penalty (no device emulation)
  • 5. DevOps - separation of concerns ○ Developer - Inside the container ○ my code ○ my libraries ○ my package manager ○ my app ○ my data ○ Operational - Outside the container ○ logging ○ remote access ○ network configuration ○ monitoring
  • 6. Docker - main features ○ a single application virtualization engine based on containers ○ a standard, reproductible way to easily build and share trusted images (Dockerfile, Stackbrew, docker-registry …) ○ each image is a stack of layers (1 layer = tarball + metadata) ○ a daemon running in the background ○ manages containers, images and builds ○ HTTP api (over UNIX or TCP socket) ○ embedded CLI talking to the api
  • 8. Docker - PaaS ○ Portability ○ Fast provisioning (Another Union File System) ○ Performance ○ processes are isolated, but run straight on the host ○ CPU performance = native performance ○ almost native memory performance ○ network performance = small overhead
  • 9. Docker - quick start ○ search an image : sudo docker search debian ○ list images : sudo docker images ○ download an image : sudo docker pull debian ○ run a container : sudo docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARGS…] ○ list all containers : sudo docker ps -a ○ find the id of the last launched container : sudo docker ps -l ○ commit container updates : sudo docker commit ID [IMAGE[:TAG]] ○ inspect a container : sudo docker inspect ID ○ upload an image : sudo docker push IMAGE
  • 10. Exercise ○ create a docker image from the latest debian image including oracle java7 as debian:oracle- java7 ○ http://www.webupd8.org/2012/06/how-to-install- oracle-java-7-in-debian.html
  • 11. Dockerfile ○ Usage : sudo docker build -t=“IMAGE[:TAG]” . ○ Format : ○ # Comment ○ INSTRUCTION arguments ○ FROM image[:TAG] ○ MAINTAINER <name> ○ RUN <command> ○ CMD [“executable","param1","param2"] | CMD [“param1","param2"] | CMD command param1 param2
  • 12. Dockerfile ○ EXPOSE <port> [<port>…] ○ ENV foo bar | ENV foo=bar ○ ADD <src>... <dest> ○ ADD hom* /mydir/ ○ ADD hom?.txt /mydir/ ○ ADD test aDir/ ○ COPY <src>... <dest> ○ ENTRYPOINT ["executable", "param1", “param2"] ○ VOLUME [“/data"] ○ WORKDIR /path/to/workdir ○ ONBUILD [INSTRUCTION]
  • 13. Dockerfile - best practices ○ add a .dockerignore file ○ avoid installing unnecessary packages ○ run only one process per container ○ minimize the number of layers ○ put long or complex RUN statements on multiple lines separated with backslashes ○ sort multi-line arguments ○ prefer COPY to ADD ○ use VOLUME for any mutable parts of your image
  • 16. Exercise ○ create a docker image from the latest debian image including oracle java7 as dockerfile/ debian:oracle-java7 using Dockerfile ○ http://www.webupd8.org/2012/06/how-to-install- oracle-java-7-in-debian.html
  • 17. Docker - overriding image defaults ○ CMD ○ sudo docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARGS...] ○ ENTRYPOINT ○ sudo docker run -i -t --entrypoint /bin/bash example/redis ○ EXPOSE (incoming ports) ○ --expose=[]: Expose a port or a range of ports from the container without binding ○ -P : bind the exposed ports to a random port on the host between 49153 and 65535 ○ -p [ip:][hostPort:]containerPort ○ --link <name or id container>:alias
  • 18. Docker - overriding image defaults ○ ENV ○ sudo docker run -e "deep=purple" --rm ubuntu /bin/bash -c export ○ VOLUME ○ -v=[]: Create a bind mount with: [host-dir]: [container-dir]:[rw|ro] ○ --volumes-from CONTAINER : share volumes with another container ○ USER ○ -u="": Username or UID ○ WORKDIR ○ -w="": Working directory inside the container
  • 19. Docker - ambassador pattern (consumer) --> (es_http_client) ---network---> (es_ambassador) --> (es) ○ vagrant ssh mogobiz-db ○ sudo docker run -d --name es -P --volumes-from elasticsearch mogobiz/ elasticsearch-1.3.6 ○ sudo docker run -d --link es:es --name es_ambassador -p 192.168.56.110:19200:9200 -p 192.168.56.110:19300:9300 svendowideit/ ambassador ○ vagrant ssh mogobiz-web ○ sudo docker run -d --name es_http_client --expose 9200 -e ELASTICSEARCH_PORT_9200_TCP=tcp://192.168.56.110:19200 svendowideit/ambassador ○ sudo docker run -t -i --rm --link es_http_client:elasticsearch --link mogobiz_db_client:mogobiz_db --name consumer -p 8080 busybox sh ○ / # env
  • 20. Ansible and docker ○ Build new image ○ Run a container