SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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