SlideShare a Scribd company logo
Rule of Two
Concerns: Build vs Runtime
1. FROM debian:jessie
# ==> Install build tools...
2. RUN apt-get update
3. RUN apt-get install -y make gcc
# ==> Compile, and install...
4. COPY . /buildContext
WORKDIR /buildContext/redis
5. RUN make
6. RUN make install
# ==> Clean up...
7. RUN apt-get remove -y --auto-remove make gcc
8. RUN apt-get clean
9. RUN rm -rf /var/lib/apt/lists/* /buildContext
# ==> Execute…
WORKDIR /
ENTRYPOINT ["redis-server"]
1. FROM debian:jessie
2. COPY . /buildContext
3. RUN apt-get update 
&& apt-get install -y make gcc 
# ==> Compile, and install...
&& cd /buildContext/redis 
&& make 
&& make install 
# ==> Clean up...
&& apt-get remove -y --auto-remove make gcc 
&& apt-get clean 
&& rm -rf /var/lib/apt/lists/* /buildContext 
# ==> Execute…
WORKDIR /
ENTRYPOINT ["redis-server"]
Build Friendly Runtime Friendly
Build Friendly Runtime Friendly
1. FROM debian:jessie
1. 1.
2. RUN apt-get update
3. RUN apt-get install –y …
4. COPY . /buildContext
5. RUN make
6. RUN make install
7. RUN apt-get remove …
8. RUN apt-get clean
9. RUN rm -rf /../lists/* … 3. 2,3,5-9
2. 4
“…neither can live while the other survives!”
docker build --squash
• Long History: #332 - 4/2013, #3116 - 12/2013, #6906 -7/2014,
#12198 - 4/2015, …
• Pull request #22641:
• Merges N physical layers into single one.
• Eliminates logically deleted files.
• How to decide which layers to preserve?
“Always two there are, no more, no less.”
Runtime Friendly = Microservice
Service Service Service
Service Service Service
Service Service Service
Service Service Service
Application
Dependencies
.
.
. Dependency Layer
Service Layer
Service layer
Depend layer
Service layer
Depend layer
Service layer
Depend layer
Service layer
Depend layer
Service layer
Depend layer
Service layer
Depend layer
Service layer
Depend layer
Service layer
Depend layer
Application
…
Build Friendly Runtime Friendly
1. FROM debian:jessie
1. 1.
2. RUN apt-get update
3. RUN apt-get install –y …
4. COPY . /buildContext
5. RUN make
6. RUN make install
7. RUN apt-get remove …
8. RUN apt-get clean
9. RUN rm -rf /../lists/* … 2-9
docker build --squash
Build Friendly Runtime Friendly
docker buld --squash
Summary
• A runtime image (microservice) consists of only 2 logical layers.
• --squash option can enforce “Rule of 2”.
• Although experimental, --squash will almost certainly be publically
available in next release.
• Future Dockerfile features will hopefully obsolesce --squash.

More Related Content

What's hot

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
 

What's hot (19)

Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Beginning mesos
Beginning mesosBeginning mesos
Beginning mesos
 
Linux server backup solution
Linux server backup solutionLinux server backup solution
Linux server backup solution
 
Devops in Networking
Devops in NetworkingDevops in Networking
Devops in Networking
 
Node.js in a heterogeneous system
Node.js in a heterogeneous systemNode.js in a heterogeneous system
Node.js in a heterogeneous system
 
Swarm docker bangalore_meetup
Swarm docker bangalore_meetupSwarm docker bangalore_meetup
Swarm docker bangalore_meetup
 
Docker Security Deep Dive by Ying Li and David Lawrence
Docker Security Deep Dive by Ying Li and David LawrenceDocker Security Deep Dive by Ying Li and David Lawrence
Docker Security Deep Dive by Ying Li and David Lawrence
 
[Js hcm] Deploying node.js with Forever.js and nginx
[Js hcm] Deploying node.js with Forever.js and nginx[Js hcm] Deploying node.js with Forever.js and nginx
[Js hcm] Deploying node.js with Forever.js and nginx
 
DevOps Practices: Configuration as Code
DevOps Practices:Configuration as CodeDevOps Practices:Configuration as Code
DevOps Practices: Configuration as Code
 
Hybrid (Windows + Linux) Apps with Docker Swarm
Hybrid (Windows + Linux) Apps with Docker SwarmHybrid (Windows + Linux) Apps with Docker Swarm
Hybrid (Windows + Linux) Apps with Docker Swarm
 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with Puppet
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Fun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker imagesFun with containers: Use Ansible to build Docker images
Fun with containers: Use Ansible to build Docker images
 
Running node.js as a service behind nginx/varnish
Running node.js as a service behind nginx/varnishRunning node.js as a service behind nginx/varnish
Running node.js as a service behind nginx/varnish
 
Cyansible
CyansibleCyansible
Cyansible
 
Fluentd and docker monitoring
Fluentd and docker monitoringFluentd and docker monitoring
Fluentd and docker monitoring
 
Continuous integration with Docker and Ansible
Continuous integration with Docker and AnsibleContinuous integration with Docker and Ansible
Continuous integration with Docker and Ansible
 
2018년 3월 정기 세미나 - March 2018 Ops Meetup 후기
2018년 3월 정기 세미나 - March 2018 Ops Meetup 후기2018년 3월 정기 세미나 - March 2018 Ops Meetup 후기
2018년 3월 정기 세미나 - March 2018 Ops Meetup 후기
 
DockerDay2015: Docker orchestration for developers
DockerDay2015: Docker orchestration for developersDockerDay2015: Docker orchestration for developers
DockerDay2015: Docker orchestration for developers
 

Viewers also liked

Lessons Learned from Dockerizing Spark Workloads
Lessons Learned from Dockerizing Spark WorkloadsLessons Learned from Dockerizing Spark Workloads
Lessons Learned from Dockerizing Spark Workloads
BlueData, Inc.
 

Viewers also liked (19)

DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Vingle tech talk #1
Vingle tech talk #1Vingle tech talk #1
Vingle tech talk #1
 
Bootstrapping Microservices
Bootstrapping MicroservicesBootstrapping Microservices
Bootstrapping Microservices
 
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
Javantura v4 - KumuluzEE – Microservices with Java - Matjaž B. Jurič & Tilen ...
 
Security enforcement of Java Microservices with Apiman & Keycloak
Security enforcement of Java Microservices with Apiman & KeycloakSecurity enforcement of Java Microservices with Apiman & Keycloak
Security enforcement of Java Microservices with Apiman & Keycloak
 
Microservice Websites (microXchg 2017)
Microservice Websites (microXchg 2017)Microservice Websites (microXchg 2017)
Microservice Websites (microXchg 2017)
 
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. JuričJavantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
Javantura v4 - Cloud-native Architectures and Java - Matjaž B. Jurič
 
Microservices Standardization - Susan Fowler, Stripe
Microservices Standardization - Susan Fowler, StripeMicroservices Standardization - Susan Fowler, Stripe
Microservices Standardization - Susan Fowler, Stripe
 
Modernizing IT with Microservices
Modernizing IT with MicroservicesModernizing IT with Microservices
Modernizing IT with Microservices
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Lessons Learned from Dockerizing Spark Workloads
Lessons Learned from Dockerizing Spark WorkloadsLessons Learned from Dockerizing Spark Workloads
Lessons Learned from Dockerizing Spark Workloads
 
Authorization and Authentication in Microservice Environments
Authorization and Authentication in Microservice EnvironmentsAuthorization and Authentication in Microservice Environments
Authorization and Authentication in Microservice Environments
 
Full lifecycle of a microservice
Full lifecycle of a microserviceFull lifecycle of a microservice
Full lifecycle of a microservice
 
Verifying Microservice Integrations with Contract Testing
Verifying Microservice Integrations with Contract TestingVerifying Microservice Integrations with Contract Testing
Verifying Microservice Integrations with Contract Testing
 
Microservices with Nancy and vs Code
Microservices with Nancy and vs CodeMicroservices with Nancy and vs Code
Microservices with Nancy and vs Code
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
 
Deploying Microservices as Containers
Deploying Microservices as ContainersDeploying Microservices as Containers
Deploying Microservices as Containers
 
Protocol buffers and Microservices
Protocol buffers and MicroservicesProtocol buffers and Microservices
Protocol buffers and Microservices
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar to Rule of two

Similar to Rule of two (20)

Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
Asian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On UblAsian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On Ubl
 
Continuous Integration & Development with Gitlab
Continuous Integration & Development with GitlabContinuous Integration & Development with Gitlab
Continuous Integration & Development with Gitlab
 
FullStack London - Cloud Native Node.js
FullStack London - Cloud Native Node.jsFullStack London - Cloud Native Node.js
FullStack London - Cloud Native Node.js
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
 
Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725
 
Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725Infrastructureascode slideshare-160331143725
Infrastructureascode slideshare-160331143725
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster management
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
 
DCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best PracticesDCSF19 Dockerfile Best Practices
DCSF19 Dockerfile Best Practices
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 

Recently uploaded

Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
The architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdfThe architecture of Generative AI for enterprises.pdf
The architecture of Generative AI for enterprises.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 

Rule of two

  • 2. Concerns: Build vs Runtime 1. FROM debian:jessie # ==> Install build tools... 2. RUN apt-get update 3. RUN apt-get install -y make gcc # ==> Compile, and install... 4. COPY . /buildContext WORKDIR /buildContext/redis 5. RUN make 6. RUN make install # ==> Clean up... 7. RUN apt-get remove -y --auto-remove make gcc 8. RUN apt-get clean 9. RUN rm -rf /var/lib/apt/lists/* /buildContext # ==> Execute… WORKDIR / ENTRYPOINT ["redis-server"] 1. FROM debian:jessie 2. COPY . /buildContext 3. RUN apt-get update && apt-get install -y make gcc # ==> Compile, and install... && cd /buildContext/redis && make && make install # ==> Clean up... && apt-get remove -y --auto-remove make gcc && apt-get clean && rm -rf /var/lib/apt/lists/* /buildContext # ==> Execute… WORKDIR / ENTRYPOINT ["redis-server"] Build Friendly Runtime Friendly
  • 3. Build Friendly Runtime Friendly 1. FROM debian:jessie 1. 1. 2. RUN apt-get update 3. RUN apt-get install –y … 4. COPY . /buildContext 5. RUN make 6. RUN make install 7. RUN apt-get remove … 8. RUN apt-get clean 9. RUN rm -rf /../lists/* … 3. 2,3,5-9 2. 4
  • 4. “…neither can live while the other survives!”
  • 5. docker build --squash • Long History: #332 - 4/2013, #3116 - 12/2013, #6906 -7/2014, #12198 - 4/2015, … • Pull request #22641: • Merges N physical layers into single one. • Eliminates logically deleted files. • How to decide which layers to preserve?
  • 6. “Always two there are, no more, no less.” Runtime Friendly = Microservice Service Service Service Service Service Service Service Service Service Service Service Service Application Dependencies . . . Dependency Layer Service Layer Service layer Depend layer Service layer Depend layer Service layer Depend layer Service layer Depend layer Service layer Depend layer Service layer Depend layer Service layer Depend layer Service layer Depend layer Application …
  • 7. Build Friendly Runtime Friendly 1. FROM debian:jessie 1. 1. 2. RUN apt-get update 3. RUN apt-get install –y … 4. COPY . /buildContext 5. RUN make 6. RUN make install 7. RUN apt-get remove … 8. RUN apt-get clean 9. RUN rm -rf /../lists/* … 2-9 docker build --squash
  • 8. Build Friendly Runtime Friendly docker buld --squash
  • 9. Summary • A runtime image (microservice) consists of only 2 logical layers. • --squash option can enforce “Rule of 2”. • Although experimental, --squash will almost certainly be publically available in next release. • Future Dockerfile features will hopefully obsolesce --squash.

Editor's Notes

  1. Notable Accomplishment: OOBash = Python. October Build VS Runtime
  2. Dockerfiles redis image showing Build Friendly vs. Runtime Friendly. Instruction numbering represents layer production. Implicit Commit performed after every Dockerfile command. A layer preserves any files committed to it. A build cache is simply a set of layers that preserve artifacts created by build tooling. A Build Friendly Dockerfile maximizes the number of layers within the build cache to improve cache utility by isolating operations that affect state to as few layers as possible. Build Friendly Dockerfiles speed development but slow deployment/dangerous increase attack surface. A Runtime Friendly Dockerfile minimizes layer creation to physically eliminate build artifacts from the image. It does so by aggregating operations that both create and delete build artifacts within the same Dockerfile command so they’re performed before committing a new layer. This speeds deployment and reduces runtime attack surface but adds friction to development builds as it negates the benefits of caching. Step through example. For example Build Friendly – Steps 1-3 are bypassed during a subsequent build of redis due to changes in redis source code.
  3. Why minimal images important? Bandwidth costs Speed Security
  4. Optimizing for one diminishes the other!
  5. Mentioned by Arun Gupta 31K range Aufs limit 42 – 127, Commit, Mark Squash Provide opinion and rational?
  6. Left Monolith = static binding of services Service – public interface/protocol business domain specific functions – like calculate contractor paycheck. Dependency – supporting functions apply a technology stacked technology http client & server Right Application – emerges from dynamically coupled microservices Reuse Runtime Layers? Dynamic binding. Dependency layer Static bindings, may be used Monolith what is it really? Optimized container network. Coupled oscillator
  7. Merges all layers up to but not including the base image. See <none><none> Runtime Friendly gets tagged – Build friendly doesn’t
  8. Who is satisfied with this solution enough to cease searching for another one? Don’t mind writing cleanup code? How to fix it? Potential better method?