SlideShare a Scribd company logo
1 of 28
Download to read offline
Dockerize a small
business
HOW DOCKER TRANSFORM OUR DEVELOPMENT & DEPLOYMENT
PROCESS
Contents
• The Dark age (Why Docker and Container matter)
• The Dockerization progress (How Docker fits in)
• Practice time
• Some useful recipes
• Example 1: Setup your own CI environments
• Example 2: Fantasy Football App
The Dark age
Modern “app” requirements
Not so thin front end app on various clients: browser, mobile, tablet
Assemble many different services from inside/outside sources
Running on any available set of physical resources (public/private/virtualized)
Modern “app” requirements
How to setup development environment fast and reliable
How to ensure services interact consistently, avoids dependencies hell
How to avoids NxN different configs
How to migrate and scale quickly, ensure compatibility across different deployment
environments
NxN compatibility nightmare
MULTIPLICITY OF STACKS
nginx + modsecurity + openssl
postgresql + postgis
hadoop + hive + thrift + OpenJDK
Ruby + Rails + sass + Unicorn
Redis + redis-sentinel
Python 3 + celery + pyredis + libcurl +
ffmpeg + libopencv + nodejs + phantomjs
Python 2.7 + Flask + pyredis + celery +
psycopg + postgresql-client
MULTIPLICITY OF DEPLOYMENT
ENVIRONMENTS
Development VM Public Cloud
Contributor’s laptop
Production Servers Production Cluster
Customer Data Center
Centos Ubuntu Debian
5 years running without package update
Outdate kernel Weird lib path
Custom repositories that no one maintained
isolation = k * repeatability
Where k is a constant that is inversely proportional to the probability of you saying "It works on
my machine".
Multiple tools for every stack to solve the isolation problem
◦ Compile your Python + virtualenv + pip + buildout + supervisord
◦ Rbenv + bundle + foreman + Capistrano + foreman
“This is like having sex with two condoms and anticonception pills.”
Still there will be inconsistency
◦ Incomplete version locks file
◦ Download cache in local machine
◦ Lack of / different version of C/C++ devel packages
Also, It takes hours to setup the environments
My code’s compiling
Virtualization saves the day
A virtual server for each app
Consistent environment
Easier for management (backup/migrate/increase resource …)
Vagrant automate dev environment setup
…for a price!
Heavy weight / expensive / slow
Different VMs for different hypervisors
Image migration between different infrastructure/PaaS providers was/is quite painful
Resource allocation is not good enough
Still takes time to setup
People need something even more lightweight/atomic
Container is the future
And Docker popularized the technology
◦ Can encapsulate almost everything and its dependencies
◦ Run consistently on any hardware without modification
◦ Resource, network and content isolation
◦ Almost no resource overhead
◦ Good set of operation: run, start, stop, commit, pull, search… Perfect for CI, CD, auto scaling, hybrid
clouds…
◦ Separation of duty: Dev worries about code, Ops worries about infrastructure
Why dev care: Build once, run anywhere
A clean, safe, hygienic and portable runtime environment for your app.
Run each app in its own isolated container, so you can run various versions of libraries and other
dependencies for each app without worrying
Reduce/eliminate concerns about compatibility on different platforms
Cheap, zero-penalty containers to deploy services
Instant replay and reset of image snapshots
Why ops care: Configure once, run
anything
Make the entire lifecycle more efficient, consistent, and repeatable
Eliminate inconsistencies between development, test, production, and customer environments
Significantly improves the speed and reliability of continuous deployment and continuous
integration systems
Because the containers are so lightweight, address significant performance, costs, deployment,
and portability issues normally associated with VMs
The Dockerization
progress
Use Docker as new building block
Thinks Service and Volume
Design apps as multiple services talk with each others via API
Each service run in 1 or multiple, replicated containers
No containers run multiple services
Design persistent bits of app as multiple volumes
A service can either rw or ro a volume
Dev describes services and dependencies via compose file
New dev use compose file to setup dev environment
Ops look at the compose file and translate/create platform specific service configuration files.
Docker-powered process
Dev
Github
Local, private
reposistory
CI service
Build image
with src
Run tests
in image
Dev
Bootstrap project with
Dockerfile and
docker-compose.yml
Clone project
$ docker-compose up
Docker-powered process
Ops
Github
Docker
reposistory
CI service
Public/private
container service
image
Build image
with src
Run tests
in image Services
configuration
Run services
Bootstrap a new project
Dev create new project with Dockerfile and docker-compose.yml
Dev declare dependencies and external services through docker-compose.yml
◦ Services start with build: . will have a .: /app volume
Dev add test/CI related files and push to github
The image is built and pushed to private docker registry
Join an ongoing project
Dev clone the repository
Dev download necessary volumes from other dev/staging server (db, configuration etc)
$ docker-compose up
Deploy and scale services
Ops look at the docker-compose file and create necessary services on the production docker
environment
Ops configure the volume storage options (nfs, ebs …)
Ops configure the forward proxy (nginx, certbot, load balancing…)
Ops run multiple containers base on the built image
Update and migrate
New app image is built and pushed into registry.
New containers are sequentially created and replace the old ones (rolling update).
If there is data need to be migrated (scheduled downtime):
◦ Stop the gateway (nginx)
◦ Hot backup the data volumes
◦ Run the migration scripts
◦ Restart the gateway
◦ Fall back is easy and instant since both old data volumes and images are there
Practice
SOME RECIPES TO BOOTSTRAP YOUR OWN DOCKERIZATION.
Docker cluster setup
#Install docker on both master and workers
yum update -y
curl -fsSL https://get.docker.com/ | sh
#Start & Enable docker service
systemctl start docker; systemctl enable docker
#On the master, Init the swarm, we don't want outsider join our swarm.
docker swarm init --listen-addr $PRIVATE_IP:2377
#On the workers, join the swarm, command is outputted from last command
docker swarm join --secret $SECRET --ca-hash $HASH $MASTER_IP:2377
#Create a services, scale the services
docker service create -p 80:8000 --name whoami jwilder/whoami
docker service scale whoami=2
#Wait containers being created and test it with curl
Nginx and Certbot
mkdir /opt/nginx
docker run -d --name nginx nginx
docker cp nginx:/etc/nginx /opt/nginx/etc
docker cp nginx:/usr/share/nginx/html /opt/nginx/www
docker stop nginx; docker rm nginx
docker run –d --name nginx --restart=always 
-p 80:80 –p 443:443 
-v /opt/nginx/etc:/etc/nginx 
-v /opt/nginx/www:/usr/share/nginx/html nginx
docker run -it --rm 
-v /opt/nginx/etc/certs:/etc/letsencrypt 
-v /opt/nginx/www:/www 
gzm55/certbot certonly --webroot -w /www –d example.com –d www.example.com
crontab –e
30 2 * * 1 docker run -it --rm -v /opt/nginx/certs:/etc/letsencrypt -v /opt/nginx/www:/www gzm55/certbot renew
>> /var/log/certbot.log
35 2 * * 1 docker exec nginx nginx -s reload
Rails quickstart
DOCKERFILE
FROM ruby:2.2.0
RUN apt-get update -qq && apt-get install
-y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp
DOCKER-COMPOSE
version: '2’
services:
db:
image: postgres
web:
build: .
command: bundle exec rails s -p 3000
-b '0.0.0.0‘
volumes:
- .:/myapp
ports:
- "3000:3000“
depends_on:
- db
Python quickstart
DOCKERFILE
FROM python:2.7
RUN mkdir /myapp
WORKDIR /myapp
ADD requirements.txt /myapp/
RUN pip install -r requirements.txt
ADD . /myapp/
DOCKER-COMPOSE
version: '2'
services:
db:
image: postgres
web:
build: .
command: python app.py
volumes:
- .:/myapp
ports:
- "5000:5000"
depends_on:
- db
Your own CI environment
Fantasy football apps

More Related Content

What's hot

Intro to docker - innovation demo 2022
Intro to docker - innovation demo 2022Intro to docker - innovation demo 2022
Intro to docker - innovation demo 2022Hussain Mansoor
 
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker, Inc.
 
DCSF19 How To Build Your Containerization Strategy
DCSF19 How To Build Your Containerization Strategy  DCSF19 How To Build Your Containerization Strategy
DCSF19 How To Build Your Containerization Strategy Docker, Inc.
 
Docker Online Meetup: Announcing Docker CE + EE
Docker Online Meetup: Announcing Docker CE + EEDocker Online Meetup: Announcing Docker CE + EE
Docker Online Meetup: Announcing Docker CE + EEDocker, Inc.
 
DCSF19 Containers for Beginners
DCSF19 Containers for BeginnersDCSF19 Containers for Beginners
DCSF19 Containers for BeginnersDocker, Inc.
 
Structured Container Delivery by Oscar Renalias, Accenture
Structured Container Delivery by Oscar Renalias, AccentureStructured Container Delivery by Oscar Renalias, Accenture
Structured Container Delivery by Oscar Renalias, AccentureDocker, Inc.
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWSAndrew Heifetz
 
Efficient Parallel Testing with Docker by Laura Frank
Efficient Parallel Testing with Docker by Laura FrankEfficient Parallel Testing with Docker by Laura Frank
Efficient Parallel Testing with Docker by Laura FrankDocker, Inc.
 
Docker Container As A Service - March 2016
Docker Container As A Service - March 2016Docker Container As A Service - March 2016
Docker Container As A Service - March 2016Patrick Chanezon
 
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...Docker, Inc.
 
Node.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and OpsNode.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and OpsBret Fisher
 
Docker?!?! But I'm a SysAdmin
Docker?!?! But I'm a SysAdminDocker?!?! But I'm a SysAdmin
Docker?!?! But I'm a SysAdminDocker, Inc.
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windowsDocker, Inc.
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker, Inc.
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker ComposeAjeet Singh Raina
 

What's hot (20)

Intro to docker - innovation demo 2022
Intro to docker - innovation demo 2022Intro to docker - innovation demo 2022
Intro to docker - innovation demo 2022
 
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
 
Docker on Docker
Docker on DockerDocker on Docker
Docker on Docker
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker basics
Docker basicsDocker basics
Docker basics
 
Docker & Kubernetes intro
Docker & Kubernetes introDocker & Kubernetes intro
Docker & Kubernetes intro
 
DCSF19 How To Build Your Containerization Strategy
DCSF19 How To Build Your Containerization Strategy  DCSF19 How To Build Your Containerization Strategy
DCSF19 How To Build Your Containerization Strategy
 
Docker Online Meetup: Announcing Docker CE + EE
Docker Online Meetup: Announcing Docker CE + EEDocker Online Meetup: Announcing Docker CE + EE
Docker Online Meetup: Announcing Docker CE + EE
 
DCSF19 Containers for Beginners
DCSF19 Containers for BeginnersDCSF19 Containers for Beginners
DCSF19 Containers for Beginners
 
Structured Container Delivery by Oscar Renalias, Accenture
Structured Container Delivery by Oscar Renalias, AccentureStructured Container Delivery by Oscar Renalias, Accenture
Structured Container Delivery by Oscar Renalias, Accenture
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
 
Efficient Parallel Testing with Docker by Laura Frank
Efficient Parallel Testing with Docker by Laura FrankEfficient Parallel Testing with Docker by Laura Frank
Efficient Parallel Testing with Docker by Laura Frank
 
Docker and stuff
Docker and stuffDocker and stuff
Docker and stuff
 
Docker Container As A Service - March 2016
Docker Container As A Service - March 2016Docker Container As A Service - March 2016
Docker Container As A Service - March 2016
 
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
Highly Available Persistent Applications in Containers by Kendrick Coleman, E...
 
Node.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and OpsNode.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and Ops
 
Docker?!?! But I'm a SysAdmin
Docker?!?! But I'm a SysAdminDocker?!?! But I'm a SysAdmin
Docker?!?! But I'm a SysAdmin
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&A
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 

Similar to ContainerDayVietnam2016: Dockerize a small business

PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...Puppet
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Simon Storm
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101Naukri.com
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDocker, Inc.
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with DockerAndrey Hristov
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with DockerAndrey Hristov
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with dockerMichelle Liu
 
Docker, Cloud Foundry, Bosh & Bluemix
Docker, Cloud Foundry, Bosh & BluemixDocker, Cloud Foundry, Bosh & Bluemix
Docker, Cloud Foundry, Bosh & BluemixIBM
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataInfluxData
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and MicroserviceSamuel Chow
 
Docker 1.9 Workshop
Docker 1.9 WorkshopDocker 1.9 Workshop
Docker 1.9 Workshop{code}
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline Docker, Inc.
 
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)Erica Windisch
 
DevAssistant, Docker and You
DevAssistant, Docker and YouDevAssistant, Docker and You
DevAssistant, Docker and YouBalaBit
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Dockernklmish
 

Similar to ContainerDayVietnam2016: Dockerize a small business (20)

PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with Docker
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with Docker
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
Docker, Cloud Foundry, Bosh & Bluemix
Docker, Cloud Foundry, Bosh & BluemixDocker, Cloud Foundry, Bosh & Bluemix
Docker, Cloud Foundry, Bosh & Bluemix
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
Docker team training
Docker team trainingDocker team training
Docker team training
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Docker 1.9 Workshop
Docker 1.9 WorkshopDocker 1.9 Workshop
Docker 1.9 Workshop
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
 
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
Practical Docker for OpenStack - NYC / PHL OpenStack meetup (4-23-2014)
 
Docker In Brief
Docker In BriefDocker In Brief
Docker In Brief
 
DevAssistant, Docker and You
DevAssistant, Docker and YouDevAssistant, Docker and You
DevAssistant, Docker and You
 
Docker
DockerDocker
Docker
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
 
Docker for dev
Docker for devDocker for dev
Docker for dev
 

More from Docker-Hanoi

ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm ModeContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm ModeDocker-Hanoi
 
ContainerDayVietnam2016: Docker 1.12 at OpenFPT
ContainerDayVietnam2016: Docker 1.12 at OpenFPTContainerDayVietnam2016: Docker 1.12 at OpenFPT
ContainerDayVietnam2016: Docker 1.12 at OpenFPTDocker-Hanoi
 
Azure Container Service
Azure Container ServiceAzure Container Service
Azure Container ServiceDocker-Hanoi
 
Docker-Ha Noi- Year end 2015 party
Docker-Ha Noi- Year end 2015 partyDocker-Ha Noi- Year end 2015 party
Docker-Ha Noi- Year end 2015 partyDocker-Hanoi
 
DockerDay2015: Introduction to OpenStack Magnum
DockerDay2015: Introduction to OpenStack MagnumDockerDay2015: Introduction to OpenStack Magnum
DockerDay2015: Introduction to OpenStack MagnumDocker-Hanoi
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: KeynoteDocker-Hanoi
 
DockerDay2015: Deploy Apps on IBM Bluemix
DockerDay2015: Deploy Apps on IBM BluemixDockerDay2015: Deploy Apps on IBM Bluemix
DockerDay2015: Deploy Apps on IBM BluemixDocker-Hanoi
 
DockerDay2015: Docker Security
DockerDay2015: Docker SecurityDockerDay2015: Docker Security
DockerDay2015: Docker SecurityDocker-Hanoi
 
DockerDay2015: Docker orchestration for developers
DockerDay2015: Docker orchestration for developersDockerDay2015: Docker orchestration for developers
DockerDay2015: Docker orchestration for developersDocker-Hanoi
 
DockerDay2015: Docker Networking
DockerDay2015: Docker NetworkingDockerDay2015: Docker Networking
DockerDay2015: Docker NetworkingDocker-Hanoi
 
DockerDay2015: Docker orchestration for sysadmin
DockerDay2015: Docker orchestration for sysadminDockerDay2015: Docker orchestration for sysadmin
DockerDay2015: Docker orchestration for sysadminDocker-Hanoi
 
DockerDay2015: Getting started with Google Container Engine
DockerDay2015: Getting started with Google Container EngineDockerDay2015: Getting started with Google Container Engine
DockerDay2015: Getting started with Google Container EngineDocker-Hanoi
 
DockerDay2015: Build and monitor a load balanced web application with Docker ...
DockerDay2015: Build and monitor a load balanced web application with Docker ...DockerDay2015: Build and monitor a load balanced web application with Docker ...
DockerDay2015: Build and monitor a load balanced web application with Docker ...Docker-Hanoi
 
DockerDay2015: Introduction to Dockerfile
DockerDay2015: Introduction to DockerfileDockerDay2015: Introduction to Dockerfile
DockerDay2015: Introduction to DockerfileDocker-Hanoi
 
DockerDay2015: Getting started with Docker
DockerDay2015: Getting started with DockerDockerDay2015: Getting started with Docker
DockerDay2015: Getting started with DockerDocker-Hanoi
 
DockerDay2015: Microsoft and Docker
DockerDay2015: Microsoft and DockerDockerDay2015: Microsoft and Docker
DockerDay2015: Microsoft and DockerDocker-Hanoi
 
DockerDay 2015: From months to minutes - How GE appliances brought docker int...
DockerDay 2015: From months to minutes - How GE appliances brought docker int...DockerDay 2015: From months to minutes - How GE appliances brought docker int...
DockerDay 2015: From months to minutes - How GE appliances brought docker int...Docker-Hanoi
 

More from Docker-Hanoi (17)

ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm ModeContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
 
ContainerDayVietnam2016: Docker 1.12 at OpenFPT
ContainerDayVietnam2016: Docker 1.12 at OpenFPTContainerDayVietnam2016: Docker 1.12 at OpenFPT
ContainerDayVietnam2016: Docker 1.12 at OpenFPT
 
Azure Container Service
Azure Container ServiceAzure Container Service
Azure Container Service
 
Docker-Ha Noi- Year end 2015 party
Docker-Ha Noi- Year end 2015 partyDocker-Ha Noi- Year end 2015 party
Docker-Ha Noi- Year end 2015 party
 
DockerDay2015: Introduction to OpenStack Magnum
DockerDay2015: Introduction to OpenStack MagnumDockerDay2015: Introduction to OpenStack Magnum
DockerDay2015: Introduction to OpenStack Magnum
 
DockerDay2015: Keynote
DockerDay2015: KeynoteDockerDay2015: Keynote
DockerDay2015: Keynote
 
DockerDay2015: Deploy Apps on IBM Bluemix
DockerDay2015: Deploy Apps on IBM BluemixDockerDay2015: Deploy Apps on IBM Bluemix
DockerDay2015: Deploy Apps on IBM Bluemix
 
DockerDay2015: Docker Security
DockerDay2015: Docker SecurityDockerDay2015: Docker Security
DockerDay2015: Docker Security
 
DockerDay2015: Docker orchestration for developers
DockerDay2015: Docker orchestration for developersDockerDay2015: Docker orchestration for developers
DockerDay2015: Docker orchestration for developers
 
DockerDay2015: Docker Networking
DockerDay2015: Docker NetworkingDockerDay2015: Docker Networking
DockerDay2015: Docker Networking
 
DockerDay2015: Docker orchestration for sysadmin
DockerDay2015: Docker orchestration for sysadminDockerDay2015: Docker orchestration for sysadmin
DockerDay2015: Docker orchestration for sysadmin
 
DockerDay2015: Getting started with Google Container Engine
DockerDay2015: Getting started with Google Container EngineDockerDay2015: Getting started with Google Container Engine
DockerDay2015: Getting started with Google Container Engine
 
DockerDay2015: Build and monitor a load balanced web application with Docker ...
DockerDay2015: Build and monitor a load balanced web application with Docker ...DockerDay2015: Build and monitor a load balanced web application with Docker ...
DockerDay2015: Build and monitor a load balanced web application with Docker ...
 
DockerDay2015: Introduction to Dockerfile
DockerDay2015: Introduction to DockerfileDockerDay2015: Introduction to Dockerfile
DockerDay2015: Introduction to Dockerfile
 
DockerDay2015: Getting started with Docker
DockerDay2015: Getting started with DockerDockerDay2015: Getting started with Docker
DockerDay2015: Getting started with Docker
 
DockerDay2015: Microsoft and Docker
DockerDay2015: Microsoft and DockerDockerDay2015: Microsoft and Docker
DockerDay2015: Microsoft and Docker
 
DockerDay 2015: From months to minutes - How GE appliances brought docker int...
DockerDay 2015: From months to minutes - How GE appliances brought docker int...DockerDay 2015: From months to minutes - How GE appliances brought docker int...
DockerDay 2015: From months to minutes - How GE appliances brought docker int...
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 

ContainerDayVietnam2016: Dockerize a small business

  • 1. Dockerize a small business HOW DOCKER TRANSFORM OUR DEVELOPMENT & DEPLOYMENT PROCESS
  • 2. Contents • The Dark age (Why Docker and Container matter) • The Dockerization progress (How Docker fits in) • Practice time • Some useful recipes • Example 1: Setup your own CI environments • Example 2: Fantasy Football App
  • 4. Modern “app” requirements Not so thin front end app on various clients: browser, mobile, tablet Assemble many different services from inside/outside sources Running on any available set of physical resources (public/private/virtualized)
  • 5. Modern “app” requirements How to setup development environment fast and reliable How to ensure services interact consistently, avoids dependencies hell How to avoids NxN different configs How to migrate and scale quickly, ensure compatibility across different deployment environments
  • 6. NxN compatibility nightmare MULTIPLICITY OF STACKS nginx + modsecurity + openssl postgresql + postgis hadoop + hive + thrift + OpenJDK Ruby + Rails + sass + Unicorn Redis + redis-sentinel Python 3 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs + phantomjs Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client MULTIPLICITY OF DEPLOYMENT ENVIRONMENTS Development VM Public Cloud Contributor’s laptop Production Servers Production Cluster Customer Data Center Centos Ubuntu Debian 5 years running without package update Outdate kernel Weird lib path Custom repositories that no one maintained
  • 7. isolation = k * repeatability Where k is a constant that is inversely proportional to the probability of you saying "It works on my machine". Multiple tools for every stack to solve the isolation problem ◦ Compile your Python + virtualenv + pip + buildout + supervisord ◦ Rbenv + bundle + foreman + Capistrano + foreman “This is like having sex with two condoms and anticonception pills.” Still there will be inconsistency ◦ Incomplete version locks file ◦ Download cache in local machine ◦ Lack of / different version of C/C++ devel packages Also, It takes hours to setup the environments
  • 9. Virtualization saves the day A virtual server for each app Consistent environment Easier for management (backup/migrate/increase resource …) Vagrant automate dev environment setup
  • 10. …for a price! Heavy weight / expensive / slow Different VMs for different hypervisors Image migration between different infrastructure/PaaS providers was/is quite painful Resource allocation is not good enough Still takes time to setup People need something even more lightweight/atomic
  • 11. Container is the future And Docker popularized the technology ◦ Can encapsulate almost everything and its dependencies ◦ Run consistently on any hardware without modification ◦ Resource, network and content isolation ◦ Almost no resource overhead ◦ Good set of operation: run, start, stop, commit, pull, search… Perfect for CI, CD, auto scaling, hybrid clouds… ◦ Separation of duty: Dev worries about code, Ops worries about infrastructure
  • 12. Why dev care: Build once, run anywhere A clean, safe, hygienic and portable runtime environment for your app. Run each app in its own isolated container, so you can run various versions of libraries and other dependencies for each app without worrying Reduce/eliminate concerns about compatibility on different platforms Cheap, zero-penalty containers to deploy services Instant replay and reset of image snapshots
  • 13. Why ops care: Configure once, run anything Make the entire lifecycle more efficient, consistent, and repeatable Eliminate inconsistencies between development, test, production, and customer environments Significantly improves the speed and reliability of continuous deployment and continuous integration systems Because the containers are so lightweight, address significant performance, costs, deployment, and portability issues normally associated with VMs
  • 15. Use Docker as new building block Thinks Service and Volume Design apps as multiple services talk with each others via API Each service run in 1 or multiple, replicated containers No containers run multiple services Design persistent bits of app as multiple volumes A service can either rw or ro a volume Dev describes services and dependencies via compose file New dev use compose file to setup dev environment Ops look at the compose file and translate/create platform specific service configuration files.
  • 16. Docker-powered process Dev Github Local, private reposistory CI service Build image with src Run tests in image Dev Bootstrap project with Dockerfile and docker-compose.yml Clone project $ docker-compose up
  • 17. Docker-powered process Ops Github Docker reposistory CI service Public/private container service image Build image with src Run tests in image Services configuration Run services
  • 18. Bootstrap a new project Dev create new project with Dockerfile and docker-compose.yml Dev declare dependencies and external services through docker-compose.yml ◦ Services start with build: . will have a .: /app volume Dev add test/CI related files and push to github The image is built and pushed to private docker registry
  • 19. Join an ongoing project Dev clone the repository Dev download necessary volumes from other dev/staging server (db, configuration etc) $ docker-compose up
  • 20. Deploy and scale services Ops look at the docker-compose file and create necessary services on the production docker environment Ops configure the volume storage options (nfs, ebs …) Ops configure the forward proxy (nginx, certbot, load balancing…) Ops run multiple containers base on the built image
  • 21. Update and migrate New app image is built and pushed into registry. New containers are sequentially created and replace the old ones (rolling update). If there is data need to be migrated (scheduled downtime): ◦ Stop the gateway (nginx) ◦ Hot backup the data volumes ◦ Run the migration scripts ◦ Restart the gateway ◦ Fall back is easy and instant since both old data volumes and images are there
  • 22. Practice SOME RECIPES TO BOOTSTRAP YOUR OWN DOCKERIZATION.
  • 23. Docker cluster setup #Install docker on both master and workers yum update -y curl -fsSL https://get.docker.com/ | sh #Start & Enable docker service systemctl start docker; systemctl enable docker #On the master, Init the swarm, we don't want outsider join our swarm. docker swarm init --listen-addr $PRIVATE_IP:2377 #On the workers, join the swarm, command is outputted from last command docker swarm join --secret $SECRET --ca-hash $HASH $MASTER_IP:2377 #Create a services, scale the services docker service create -p 80:8000 --name whoami jwilder/whoami docker service scale whoami=2 #Wait containers being created and test it with curl
  • 24. Nginx and Certbot mkdir /opt/nginx docker run -d --name nginx nginx docker cp nginx:/etc/nginx /opt/nginx/etc docker cp nginx:/usr/share/nginx/html /opt/nginx/www docker stop nginx; docker rm nginx docker run –d --name nginx --restart=always -p 80:80 –p 443:443 -v /opt/nginx/etc:/etc/nginx -v /opt/nginx/www:/usr/share/nginx/html nginx docker run -it --rm -v /opt/nginx/etc/certs:/etc/letsencrypt -v /opt/nginx/www:/www gzm55/certbot certonly --webroot -w /www –d example.com –d www.example.com crontab –e 30 2 * * 1 docker run -it --rm -v /opt/nginx/certs:/etc/letsencrypt -v /opt/nginx/www:/www gzm55/certbot renew >> /var/log/certbot.log 35 2 * * 1 docker exec nginx nginx -s reload
  • 25. Rails quickstart DOCKERFILE FROM ruby:2.2.0 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs RUN mkdir /myapp WORKDIR /myapp ADD Gemfile /myapp/Gemfile ADD Gemfile.lock /myapp/Gemfile.lock RUN bundle install ADD . /myapp DOCKER-COMPOSE version: '2’ services: db: image: postgres web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0‘ volumes: - .:/myapp ports: - "3000:3000“ depends_on: - db
  • 26. Python quickstart DOCKERFILE FROM python:2.7 RUN mkdir /myapp WORKDIR /myapp ADD requirements.txt /myapp/ RUN pip install -r requirements.txt ADD . /myapp/ DOCKER-COMPOSE version: '2' services: db: image: postgres web: build: . command: python app.py volumes: - .:/myapp ports: - "5000:5000" depends_on: - db
  • 27. Your own CI environment