SlideShare a Scribd company logo
1 of 13
Download to read offline
docker build 

with Ansible
Application construction
with Ansible
• vagrant, local mode
• packer, image creation
• cloud & bare metal provisioning
• deployment & remote execution
Application construction
with Dockerfile
• Dockerfile is the Docker way
• Each instruction creates a layer
• Lots of bash commands
• Maintainability? Testability?
• Portability?
Demo
• https://github.com/
bbaassssiiee/truedemo.git
tree
.  
|-­-­  Dockerfile  
|-­-­  Makefile  
|-­-­  ansible  
|      |-­-­  ansible.cfg  
|      |-­-­  hosts  
|      |-­-­  playbook.yml  
|      |-­-­  requirements.yml  
|      `-­-­  vars.yml  
`-­-­  webapps  
        `-­-­  gameoflife.war  
2  directories,  8  files
Dockerfile
FROM  centos:centos7  
MAINTAINER  Bas  Meijer  <bas.meijer@me.com>  
LABEL  running="docker  run  -­d  -­p  8080:8080  dockpack/tomcat:7"  
ADD  ansible  /tmp/ansible  
RUN  yum  update  -­y  &&    
        yum  install  -­y  epel-­release  &&    
        yum  install  -­y  ansible  tar  &&    
        yum  clean  all  &&    
        cd  /tmp/ansible  &&    
        ansible-­galaxy  install  -­-­force  -­r  requirements.yml  &&    
        ansible-­playbook  playbook.yml  
ADD  webapps  /opt/apache-­tomcat/webapps  
ENV  CATALINA_HOME  /opt/apache-­tomcat  
ENV  PATH  $CATALINA_HOME/bin:$PATH  
WORKDIR  $CATALINA_HOME  
EXPOSE  8080  
ENTRYPOINT  ["/opt/apache-­tomcat/bin/catalina.sh","run"]  
Makefile
AUTHOR=dockpack  
NAME=tomcat  
VERSION=7  
.PHONY:  all  build  bash  run  help  
all:  build  
build:  
   docker  build  -­t  $(AUTHOR)/$(NAME):$(VERSION)  .  
bash:  
   docker  exec  -­ti  dockpacktomcat  /bin/bash  
run:  
   docker  run  -­-­name  dockpacktomcat  -­h  dockpacktomcat  -­d  -­p  8080:8080  $
(AUTHOR)/$(NAME):$(VERSION)  
help:  
   @docker  inspect  $(AUTHOR)/$(NAME):$(VERSION)  |  grep  -­i  running  |  head  -­1  
test:  
   open  http://$(DOCKERHOST):8080/gameoflife/  
playbook.yml
-­-­-­  
-­  hosts:  docker  
    connection:  local  
    user:  root  
    gather_facts:  False  
    vars_files:  
        -­  vars.yml  
    roles:  
        -­  geerlingguy.java  
        -­  hudecof.tomcat  
docker build
docker  build  -­t  dockpack/tomcat:7  .  
Sending  build  context  to  Docker  daemon  6.578  MB  
Step  0  :  FROM  centos:centos7  
  -­-­-­>  ce20c473cd8a  
Step  1  :  MAINTAINER  Bas  Meijer  <bas.meijer@me.com>  
  -­-­-­>  Running  in  5e577b479ab4  
  -­-­-­>  836c1c700c00  
Removing  intermediate  container  5e577b479ab4  
Step  2  :  LABEL  running  "docker  run  -­d  -­p  8080:8080  dockpack/tomcat:7"  
  -­-­-­>  Running  in  56b9e596adc7  
  -­-­-­>  2b0f03a6e415  
Removing  intermediate  container  56b9e596adc7  
Step  3  :  ADD  ansible  /tmp/ansible  
  -­-­-­>  b282cb737950  
Removing  intermediate  container  b20ea1f41fef  
Step  4  :  RUN  yum  update  -­y  &&          yum  install  -­y  epel-­release  &&          
yum  install  -­y  ansible  tar  &&          yum  clean  all  &&          cd  /tmp/ansible  
&&          ansible-­galaxy  install  -­-­force  -­r  requirements.yml  &&          
ansible-­playbook  playbook.yml  
  -­-­-­>  Running  in  8ed5acb65b06  
docker build
  -­-­-­>  600eb11ee771  
Removing  intermediate  container  8ed5acb65b06  
Step  5  :  ADD  webapps  /opt/apache-­tomcat/webapps  
  -­-­-­>  4db505c0ad3a  
Removing  intermediate  container  9ef85479e13b  
Step  6  :  ENV  CATALINA_HOME  /opt/apache-­tomcat  
  -­-­-­>  Running  in  e0898552f75b  
  -­-­-­>  acd4777b6cff  
Removing  intermediate  container  e0898552f75b  
Step  7  :  ENV  PATH  $CATALINA_HOME/bin:$PATH  
  -­-­-­>  Running  in  cd95c5057ae6  
  -­-­-­>  3757a691866e  
Removing  intermediate  container  cd95c5057ae6  
Step  8  :  WORKDIR  $CATALINA_HOME  
  -­-­-­>  Running  in  10ffaf35619e  
  -­-­-­>  ffae6214c059  
Removing  intermediate  container  10ffaf35619e  
Step  9  :  EXPOSE  8080  
  -­-­-­>  Running  in  d728ed59907a  
  -­-­-­>  729cb0905aa4  
Removing  intermediate  container  d728ed59907a  
Step  10  :  ENTRYPOINT  /opt/apache-­tomcat/bin/catalina.sh  run  
  -­-­-­>  Running  in  d3014eaa2706  
  -­-­-­>  d73eddf84268  
Removing  intermediate  container  d3014eaa2706  
Successfully  built  d73eddf84268
ansible is 27 Mb
Installing:  
  ansible                                                            noarch    1.9.4-­1.el7                  epel        1.7  M  
Installing  for  dependencies:  
  PyYAML                                                              x86_64    3.10-­11.el7                  base        153  k  
  libyaml                                                            x86_64    0.1.4-­11.el7_0            base          55  k  
  python-­babel                                                  noarch    0.9.6-­8.el7                  base        1.4  M  
  python-­backports                                          x86_64    1.0-­8.el7                      base        5.8  k  
  python-­backports-­ssl_match_hostname    noarch    3.4.0.2-­4.el7              base          12  k  
  python-­crypto                                                x86_64    2.6.1-­1.el7.centos    extras    470  k  
  python-­ecdsa                                                  noarch    0.11-­3.el7.centos      extras      69  k  
  python-­httplib2                                            noarch    0.7.7-­3.el7                  epel          70  k  
  python-­jinja2                                                noarch    2.7.2-­2.el7                  base        515  k  
  python-­keyczar                                              noarch    0.71c-­2.el7                  epel        218  k  
  python-­markupsafe                                        x86_64    0.11-­10.el7                  base          25  k  
  python-­paramiko                                            noarch    1.15.1-­1.el7                epel        999  k  
  python-­pyasn1                                                noarch    0.1.6-­2.el7                  base          91  k  
  python-­setuptools                                        noarch    0.9.8-­3.el7                  base        396  k  
  python-­six                                                      noarch    1.3.0-­4.el7                  base          18  k  
  sshpass                                                            x86_64    1.05-­5.el7                    epel          21  k  
Transaction  Summary  
================================================================================  
Install    1  Package  (+16  Dependent  packages)  
Total  download  size:  6.1  M  
Installed  size:  27  M  
docker build with Ansible
• postpone decision how to run
• re-use app construction plays
• well-structured Ansible
• reduce number of layers
• little extra space
That`s all folks!

More Related Content

What's hot

What's hot (20)

Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptop
 
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
Ansible Automation Best Practices From Startups to Enterprises - Minnebar 12
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Ansible
AnsibleAnsible
Ansible
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Jenkins and ansible reference
Jenkins and ansible referenceJenkins and ansible reference
Jenkins and ansible reference
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Testing with Ansible
Testing with AnsibleTesting with Ansible
Testing with Ansible
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)Go Faster with Ansible (AWS meetup)
Go Faster with Ansible (AWS meetup)
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Ansible for beginners
Ansible for beginnersAnsible for beginners
Ansible for beginners
 

Viewers also liked

Viewers also liked (7)

Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Cyansible
CyansibleCyansible
Cyansible
 
AnsibleBuilding a Docker-ized Microservice In Node, Using Ansible - AnsibleF...
AnsibleBuilding a Docker-ized Microservice  In Node, Using Ansible - AnsibleF...AnsibleBuilding a Docker-ized Microservice  In Node, Using Ansible - AnsibleF...
AnsibleBuilding a Docker-ized Microservice In Node, Using Ansible - AnsibleF...
 
V2 and beyond
V2 and beyondV2 and beyond
V2 and beyond
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 

Similar to docker build with Ansible

Shipping python project by docker
Shipping python project by dockerShipping python project by docker
Shipping python project by docker
Wei-Ting Kuo
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
Munish Mehta
 

Similar to docker build with Ansible (20)

Shipping python project by docker
Shipping python project by dockerShipping python project by docker
Shipping python project by docker
 
Docker as an every day work tool
Docker as an every day work toolDocker as an every day work tool
Docker as an every day work tool
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
AstriCon 2017 - Docker Swarm & Asterisk
AstriCon 2017  - Docker Swarm & AsteriskAstriCon 2017  - Docker Swarm & Asterisk
AstriCon 2017 - Docker Swarm & Asterisk
 
OTRS
OTRSOTRS
OTRS
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
 
Dockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and NovaDockerizing the Hard Services: Neutron and Nova
Dockerizing the Hard Services: Neutron and Nova
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
 
Metal-k8s presentation by Julien Girardin @ Paris Kubernetes Meetup
Metal-k8s presentation by Julien Girardin @ Paris Kubernetes MeetupMetal-k8s presentation by Julien Girardin @ Paris Kubernetes Meetup
Metal-k8s presentation by Julien Girardin @ Paris Kubernetes Meetup
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
stackconf 2022: Cluster Management: Heterogeneous, Lightweight, Safe. Pick Three
stackconf 2022: Cluster Management: Heterogeneous, Lightweight, Safe. Pick Threestackconf 2022: Cluster Management: Heterogeneous, Lightweight, Safe. Pick Three
stackconf 2022: Cluster Management: Heterogeneous, Lightweight, Safe. Pick Three
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
 
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDrupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

docker build with Ansible

  • 2. Application construction with Ansible • vagrant, local mode • packer, image creation • cloud & bare metal provisioning • deployment & remote execution
  • 3. Application construction with Dockerfile • Dockerfile is the Docker way • Each instruction creates a layer • Lots of bash commands • Maintainability? Testability? • Portability?
  • 5. tree .   |-­-­  Dockerfile   |-­-­  Makefile   |-­-­  ansible   |      |-­-­  ansible.cfg   |      |-­-­  hosts   |      |-­-­  playbook.yml   |      |-­-­  requirements.yml   |      `-­-­  vars.yml   `-­-­  webapps          `-­-­  gameoflife.war   2  directories,  8  files
  • 6. Dockerfile FROM  centos:centos7   MAINTAINER  Bas  Meijer  <bas.meijer@me.com>   LABEL  running="docker  run  -­d  -­p  8080:8080  dockpack/tomcat:7"   ADD  ansible  /tmp/ansible   RUN  yum  update  -­y  &&            yum  install  -­y  epel-­release  &&            yum  install  -­y  ansible  tar  &&            yum  clean  all  &&            cd  /tmp/ansible  &&            ansible-­galaxy  install  -­-­force  -­r  requirements.yml  &&            ansible-­playbook  playbook.yml   ADD  webapps  /opt/apache-­tomcat/webapps   ENV  CATALINA_HOME  /opt/apache-­tomcat   ENV  PATH  $CATALINA_HOME/bin:$PATH   WORKDIR  $CATALINA_HOME   EXPOSE  8080   ENTRYPOINT  ["/opt/apache-­tomcat/bin/catalina.sh","run"]  
  • 7. Makefile AUTHOR=dockpack   NAME=tomcat   VERSION=7   .PHONY:  all  build  bash  run  help   all:  build   build:     docker  build  -­t  $(AUTHOR)/$(NAME):$(VERSION)  .   bash:     docker  exec  -­ti  dockpacktomcat  /bin/bash   run:     docker  run  -­-­name  dockpacktomcat  -­h  dockpacktomcat  -­d  -­p  8080:8080  $ (AUTHOR)/$(NAME):$(VERSION)   help:     @docker  inspect  $(AUTHOR)/$(NAME):$(VERSION)  |  grep  -­i  running  |  head  -­1   test:     open  http://$(DOCKERHOST):8080/gameoflife/  
  • 8. playbook.yml -­-­-­   -­  hosts:  docker      connection:  local      user:  root      gather_facts:  False      vars_files:          -­  vars.yml      roles:          -­  geerlingguy.java          -­  hudecof.tomcat  
  • 9. docker build docker  build  -­t  dockpack/tomcat:7  .   Sending  build  context  to  Docker  daemon  6.578  MB   Step  0  :  FROM  centos:centos7    -­-­-­>  ce20c473cd8a   Step  1  :  MAINTAINER  Bas  Meijer  <bas.meijer@me.com>    -­-­-­>  Running  in  5e577b479ab4    -­-­-­>  836c1c700c00   Removing  intermediate  container  5e577b479ab4   Step  2  :  LABEL  running  "docker  run  -­d  -­p  8080:8080  dockpack/tomcat:7"    -­-­-­>  Running  in  56b9e596adc7    -­-­-­>  2b0f03a6e415   Removing  intermediate  container  56b9e596adc7   Step  3  :  ADD  ansible  /tmp/ansible    -­-­-­>  b282cb737950   Removing  intermediate  container  b20ea1f41fef   Step  4  :  RUN  yum  update  -­y  &&          yum  install  -­y  epel-­release  &&           yum  install  -­y  ansible  tar  &&          yum  clean  all  &&          cd  /tmp/ansible   &&          ansible-­galaxy  install  -­-­force  -­r  requirements.yml  &&           ansible-­playbook  playbook.yml    -­-­-­>  Running  in  8ed5acb65b06  
  • 10. docker build  -­-­-­>  600eb11ee771   Removing  intermediate  container  8ed5acb65b06   Step  5  :  ADD  webapps  /opt/apache-­tomcat/webapps    -­-­-­>  4db505c0ad3a   Removing  intermediate  container  9ef85479e13b   Step  6  :  ENV  CATALINA_HOME  /opt/apache-­tomcat    -­-­-­>  Running  in  e0898552f75b    -­-­-­>  acd4777b6cff   Removing  intermediate  container  e0898552f75b   Step  7  :  ENV  PATH  $CATALINA_HOME/bin:$PATH    -­-­-­>  Running  in  cd95c5057ae6    -­-­-­>  3757a691866e   Removing  intermediate  container  cd95c5057ae6   Step  8  :  WORKDIR  $CATALINA_HOME    -­-­-­>  Running  in  10ffaf35619e    -­-­-­>  ffae6214c059   Removing  intermediate  container  10ffaf35619e   Step  9  :  EXPOSE  8080    -­-­-­>  Running  in  d728ed59907a    -­-­-­>  729cb0905aa4   Removing  intermediate  container  d728ed59907a   Step  10  :  ENTRYPOINT  /opt/apache-­tomcat/bin/catalina.sh  run    -­-­-­>  Running  in  d3014eaa2706    -­-­-­>  d73eddf84268   Removing  intermediate  container  d3014eaa2706   Successfully  built  d73eddf84268
  • 11. ansible is 27 Mb Installing:    ansible                                                            noarch    1.9.4-­1.el7                  epel        1.7  M   Installing  for  dependencies:    PyYAML                                                              x86_64    3.10-­11.el7                  base        153  k    libyaml                                                            x86_64    0.1.4-­11.el7_0            base          55  k    python-­babel                                                  noarch    0.9.6-­8.el7                  base        1.4  M    python-­backports                                          x86_64    1.0-­8.el7                      base        5.8  k    python-­backports-­ssl_match_hostname    noarch    3.4.0.2-­4.el7              base          12  k    python-­crypto                                                x86_64    2.6.1-­1.el7.centos    extras    470  k    python-­ecdsa                                                  noarch    0.11-­3.el7.centos      extras      69  k    python-­httplib2                                            noarch    0.7.7-­3.el7                  epel          70  k    python-­jinja2                                                noarch    2.7.2-­2.el7                  base        515  k    python-­keyczar                                              noarch    0.71c-­2.el7                  epel        218  k    python-­markupsafe                                        x86_64    0.11-­10.el7                  base          25  k    python-­paramiko                                            noarch    1.15.1-­1.el7                epel        999  k    python-­pyasn1                                                noarch    0.1.6-­2.el7                  base          91  k    python-­setuptools                                        noarch    0.9.8-­3.el7                  base        396  k    python-­six                                                      noarch    1.3.0-­4.el7                  base          18  k    sshpass                                                            x86_64    1.05-­5.el7                    epel          21  k   Transaction  Summary   ================================================================================   Install    1  Package  (+16  Dependent  packages)   Total  download  size:  6.1  M   Installed  size:  27  M  
  • 12. docker build with Ansible • postpone decision how to run • re-use app construction plays • well-structured Ansible • reduce number of layers • little extra space