SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
Docker Distributed
Application Bundle &
Stack
20th Aug 2016, Docker Bangalore Meetup,
RedHat India Pvt. Ltd.
Thomas Chacko
thomasch (at ) iconnexions.com
Distributed Application Bundle & Stack
Advisory: The functionality described here is marked as experimental, and as such, may
change before it becomes GA.
• Real-world applications are complex - codebases, stacks, databases, queues,
networks..
• Deploy and managing using docker compose and service to start/stop and link
individual containers / service not efficient within production environment
• Introducing DAB :: Experimental open file format to bundle and distribute all
artefacts for a real-world multi-container, multi-host, multi-tiered networked
applications
• High level abstraction - leverages all new features of Docker 1.12 ( swarm - orchestration &
load balancing, services, nodes etc ).
• DAB describes ( JSON ) :
• all services required
• images
• ports to expose
• networks used to link services
• etc…
Distributed Application Bundle & Stack
• Requires docker-compose 1.8 and docker 1.12. Developers use docker-compose to
create DABs and Ops deploys these stacks using docker.
• Image is a portable format for a single container file

• Distributed Application Bundle or DAB is a light-weight portable format for multiple
containers. Each bundle can be deployed as a Stack at run-time in production.
DAB in action - demo
Front End Back End
• Python webapp which lets you vote
between several options

• Node.js /AngularJS webapp showing
the results of the poll in real time
• Redis Queue to collect new votes

• Java Worker which consumes
votes and stores them in the
database

• Postgres database backed by a
Docker Volume
related command synopsis
$	docker-compose	bundle	--help	
Generate	 a	 Distributed	 Application	 Bundle	 (DAB)	 from	 the	 Compose	 file	 .	 Images	 must	 have	 digests	 stored,	 which	 requires	
interaction	with	a	Docker	registry.	If	digests	aren't	stored	for	all	images,	you	can	fetch	them	with	`docker-compose	pull`	or	`docker-
compose	push`.	To	push	images	automatically	when	bundling,	pass	`--push-images`.	Only	services	with	a	`build`	option	specified	will	
have	their	images	pushed.	
Usage:	bundle	[options]	
Options:	
		--push-images										Automatically	push	images	for	any	services	
																																			which	have	a	`build`	option	specified.	
				-o,	--output	PATH		Path	to	write	the	bundle	file	to.	
																																			Defaults	to	"<project	name>.dab”.	
$	docker	deploy	--help	
Usage:		 docker	deploy	[OPTIONS]	STACK	
Create	and	update	a	stack	from	a	Distributed	Application	Bundle	(DAB)	
Options:	
			--file	string																				Path	to	a	Distributed	Application	Bundle	file	(Default:	STACK.dab)	
					--help																													Print	usage	
					--with-registry-auth				Send	registry	authentication	details	to	Swarm	agents
related command synopsis..cont
$	docker	stack	--help	
Usage:		 docker	stack	COMMAND	
Manage	Docker	stacks	
Options:	
						--help			Print	usage	
Commands:	
		config						Print	the	stack	configuration	
		deploy					Create	and	update	a	stack	from	a	Distributed	Application	Bundle	(DAB)	
		rm												Remove	the	stack	
		ps													List	the	tasks	in	the	stack
Docker Compose vs DAB
• Docker Compose is a client side tool presently used in development / test workflow
• Docker DAB is ( specifically intended ) to be used at scale and server side orchestration
within production environment. Bundle deployment is an integral function of docker 1.12
engine. Stack can be deployed on a docker 1.12 swarm cluster only.
• DAB can deploy non-containerised app also.
• more (?)
Playbook : swarm/dab local test setup 1/4
• Pre-requisite : one Host PC or laptop : Windows 7+, MacOS X 10.11+, any modern Linux
with 3.10+ kernel ( recommended, Redhat/Centos/Ubuntu) with min 4GB ( 8GB
recomended) RAM and 20GB free hard disk.
• For Windows and OSX, one can install docker toolbox from https://docs.docker.com/
toolbox/overview/. Additionally can install docker for windows or OSX client also. For
Linux, install latest docker ver 1.12+ client /server , compose 1.8 from https://
docs.docker.com/engine/getstarted/step_one/ . Docker toolbox on OSX and Windows also
installs Oracle Virtualbox ; for Linux install it from https://www.virtualbox.org/wiki/
Downloads
• Create a docker hub/cloud login account ( https://cloud.docker.com/ - req only if one wish
to build custom images and push/pull from docker hub repository)
• Now we are ready to setup nodes and a swarm cluster on it
• Note : This playbook is for local VM setup. One can alternatively spin up machines on any
public cloud and follow this guide accordingly.
We will setup a simple 3 node swarm with 1 leader (master ) using docker-machine
Create the nodes :
$ docker-machine create -d virtualbox master
$ docker-machine create -d virtualbox node-1
$ docker-machine create -d virtualbox node-2
Inspect/configure the VM nodes created :
$ docker-machine ls
Note : VirtualBox will generally provision 2 networks : one NAT for internet and one Host-only networking whose IP will be
dynamically allotted with each reboots. This changing DHCP IP allocation will break our docker PKI and swarm config on
node reboots and hence the workaround presently is a tweak script here which can make this IP static ( Ref : https://
github.com/fivestars/docker-machine-ipconfig). Immediately after the VMs are created and docker provisioned - use the
above docker-machine-ipconfig cmd and make these ips static. The other option is to bypass docker-machine and instead
directly use vagrant/puppet/chef scripts with fixed ip declaration.
Recommended ( not mandatory ) - Add the ip address for all 3 nodes from ‘docker-machine ls’ cmd above to /etc/hosts on
the host OS machine. This playbook assumes such and refers nodes with their host name here viz. ( master , node-1 ,
node-2 ). Recommended to edit VM settings and set all the 3 node VMs memory to 1GB (min, recomended 2GB) each.
Roll out the swarm cluster network :
(Optional ) If docker for Windows or OSX client was also installed, then we need to point this local docker client to the
Docker engine on master node by setting DOCKER_* environment variables using :
$ eval $( docker-machine env master )
Lets initialise the swarm network on master node.
$ docker-machine ssh master
master $ docker swarm init — listen-addr=192.168.99.103:2733 —advertise-addr=192.168.99.103:2733
The - - advertise-addr above is required because of 2 network interface on these VMs. Substitute 192.168.99.103 above
with your master node ip from ‘docker-machine ls’. The above command will return an URL with a swarm token string to be
run on each worker nodes. SSH to each worker nodes and copy/paste this command on it
$ docker-machine ssh node-1
node-1 $ ( copy/paste the above join command here )
repeat above for node-2. The docker swarm cluster is setup .
Checkout the Docker swarm cluster members . PS: all commands further down are assumed to be run against master node.
$ docker node ls
This will show the three nodes with the elected leader node(s) tagged.
Playbook : swarm/dab test-setup 2/4
Test setup the classic voting app ( thanks to Docker )
Option -1 Download/ build the images required for this Docker playbook
$ git clone https://github.com/docker/example-voting-app.git
$ cd example-voting-app
There are 5 services , one can modify the script to change the poll options etc. refer git read me.
$ cd vote
$ docker build --no-cache -t thomasch/votingapp_voting-app .
{ replace thomasch here in all the image name(s) with your docker-hub id or name }
$ cd worker
$ docker build --no-cache -t thomasch/votingapp_worker .
$ cd result
$ docker build --no-cache -t thomasch/votingapp_result-app .
We will push these images to docker repository ( also create image digest )
$ docker login
{ provide docker hub/cloud username and password when prompted }
$ docker push thomasch/votingapp_voting-app
$ docker push thomasch/votingapp_worker
$ docker push thomasch/votingapp_result-app
{ use corrected docker image names above }
Option-2 OR ALTERNATIVELY instead of Option-1 , [ only if you trust them :) ] - you can pull these images directly
from my docker public repository
$ docker pull thomasch/votingapp_voting-app
$ docker pull thomasch/votingapp_worker
$ docker pull thomasch/votingapp_result-app
Inspect the docker-compose.yml file in the example-voting-app folder. This file has to be slightly modified to be dab
conversion compatible . Check/download the final edited version here :
https://gist.github.com/thomgit/c0ddfcded35f986055e391442c83bda9
Copy this yml file to a new directory. Review and update the images names if you have changed them during custom
build above in Option-1.
Playbook : swarm/dab test-build 3/4
Convert the compose YAML to DAB format and test stack and swarm workflow
cd to the directory with modified docker-compose.yml file and covert this to .DAB format
first pull the remaining images required for this voting app from public repository - redis, postgres
$ docker-compose pull vote, redis, worker , db, result
convert the docker-compose yaml file to JSON dab format using docker-compose client tool ( >ver 1.8 )
$ docker-compose bundle -o votingapp.dab.
deploy this dab file on the swarm cluster we setup
$ docker deploy votingapp
This will deploy 5 services - it might take time for all the 5 services to start. Check the stack services status using
$ docker stack ps votingapp
Inspect the ‘PublishedPort’ for votingapp_vote and votingapp_result. These port(s) should be in 30000+ range.
$ docker service inspect votingapp_vote --pretty
$ docker service inspect votingapp_result --pretty
The voting and results front-end will be available in the host machine browser on any ( swarm mesh network feature ) node
cluster ip address ( e.g. http://192.168.99.xx: <PublshedPort> ). Test the vote page and see the real-time poll results
displayed by the node.js/AngularJS result app page.
We have stood-up an entire application stack now . The new ‘docker stack’ CLI can be used to manage all the services
together in this stack:
check the stack configuration
$ docker stack config votingapp
delete the entire stack
$ docker stack rm votingapp
Additional suggested activity
Use this docker swarm cluster to :
• test scale-up/down the votingapp_vote service
• drain any one node and see how swarm reschedules the services to other node(s) to maintain the desired state of stack
• create a new version of votingapp_vote_v2 and check out rolling upgrades.
Hope this help get a reasonable grip on these exciting new docker 1.12 features...
Playbook : swarm/dab test-run 3/4

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Dockerizing Windows Server Applications by Ender Barillas and Taylor Brown
Dockerizing Windows Server Applications by Ender Barillas and Taylor BrownDockerizing Windows Server Applications by Ender Barillas and Taylor Brown
Dockerizing Windows Server Applications by Ender Barillas and Taylor Brown
 
Docker Swarm & Machine
Docker Swarm & MachineDocker Swarm & Machine
Docker Swarm & Machine
 
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16 What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
 
Dockercon 16 Wrap-up (Docker for Mac and Win, Docker 1.12, Swarm Mode, etc.)
Dockercon 16 Wrap-up (Docker for Mac and Win, Docker 1.12, Swarm Mode, etc.)Dockercon 16 Wrap-up (Docker for Mac and Win, Docker 1.12, Swarm Mode, etc.)
Dockercon 16 Wrap-up (Docker for Mac and Win, Docker 1.12, Swarm Mode, etc.)
 
Deep Dive into Docker Swarm Mode
Deep Dive into Docker Swarm ModeDeep Dive into Docker Swarm Mode
Deep Dive into Docker Swarm Mode
 
Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
 
CoreOS Overview and Current Status
CoreOS Overview and Current StatusCoreOS Overview and Current Status
CoreOS Overview and Current Status
 
Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017Why Docker? Dayton PHP, April 2017
Why Docker? Dayton PHP, April 2017
 
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
Using Docker Swarm Mode to Deploy Service Without Loss by Dongluo Chen & Nish...
 
Docker Overview
Docker OverviewDocker Overview
Docker Overview
 
Ansible docker
Ansible dockerAnsible docker
Ansible docker
 
Monitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & MicroservicesMonitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & Microservices
 
Comprehensive Monitoring for Docker
Comprehensive Monitoring for DockerComprehensive Monitoring for Docker
Comprehensive Monitoring for Docker
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
Cloning Running Servers with Docker and CRIU by Ross Boucher
Cloning Running Servers with Docker and CRIU by Ross BoucherCloning Running Servers with Docker and CRIU by Ross Boucher
Cloning Running Servers with Docker and CRIU by Ross Boucher
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
Building Reusable Development Environments with Docker
Building Reusable Development Environments with DockerBuilding Reusable Development Environments with Docker
Building Reusable Development Environments with Docker
 
Docker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesDocker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notes
 
Rapid Development With Docker Compose
Rapid Development With Docker ComposeRapid Development With Docker Compose
Rapid Development With Docker Compose
 
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerUnder the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
 

Semelhante a Docker Distributed application bundle & Stack - Overview

Be a Happier Developer with Docker: Tricks of the Trade
Be a Happier Developer with Docker: Tricks of the TradeBe a Happier Developer with Docker: Tricks of the Trade
Be a Happier Developer with Docker: Tricks of the Trade
Docker, Inc.
 

Semelhante a Docker Distributed application bundle & Stack - Overview (20)

Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker Compose Explained
Docker Compose ExplainedDocker Compose Explained
Docker Compose Explained
 
Docker advance topic
Docker advance topicDocker advance topic
Docker advance topic
 
Docker advance1
Docker advance1Docker advance1
Docker advance1
 
Intersog Hack_n_Tell. Docker. First steps.
Intersog Hack_n_Tell. Docker. First steps.Intersog Hack_n_Tell. Docker. First steps.
Intersog Hack_n_Tell. Docker. First steps.
 
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz LachJDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
 
Online Meetup: What's new in docker 1.13.0
Online Meetup: What's new in docker 1.13.0 Online Meetup: What's new in docker 1.13.0
Online Meetup: What's new in docker 1.13.0
 
Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
 
Tips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podmanTips pour sécuriser ses conteneurs docker/podman
Tips pour sécuriser ses conteneurs docker/podman
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Be a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the tradeBe a happier developer with Docker: Tricks of the trade
Be a happier developer with Docker: Tricks of the trade
 
Effective images remix
Effective images remixEffective images remix
Effective images remix
 
Docker Basic to Advance
Docker Basic to AdvanceDocker Basic to Advance
Docker Basic to Advance
 
Academy PRO: Docker. Lecture 3
Academy PRO: Docker. Lecture 3Academy PRO: Docker. Lecture 3
Academy PRO: Docker. Lecture 3
 
Be a Happier Developer with Docker: Tricks of the Trade
Be a Happier Developer with Docker: Tricks of the TradeBe a Happier Developer with Docker: Tricks of the Trade
Be a Happier Developer with Docker: Tricks of the Trade
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Docker Distributed application bundle & Stack - Overview

  • 1. Docker Distributed Application Bundle & Stack 20th Aug 2016, Docker Bangalore Meetup, RedHat India Pvt. Ltd. Thomas Chacko thomasch (at ) iconnexions.com
  • 2. Distributed Application Bundle & Stack Advisory: The functionality described here is marked as experimental, and as such, may change before it becomes GA. • Real-world applications are complex - codebases, stacks, databases, queues, networks.. • Deploy and managing using docker compose and service to start/stop and link individual containers / service not efficient within production environment • Introducing DAB :: Experimental open file format to bundle and distribute all artefacts for a real-world multi-container, multi-host, multi-tiered networked applications • High level abstraction - leverages all new features of Docker 1.12 ( swarm - orchestration & load balancing, services, nodes etc ). • DAB describes ( JSON ) : • all services required • images • ports to expose • networks used to link services • etc…
  • 3. Distributed Application Bundle & Stack • Requires docker-compose 1.8 and docker 1.12. Developers use docker-compose to create DABs and Ops deploys these stacks using docker. • Image is a portable format for a single container file
 • Distributed Application Bundle or DAB is a light-weight portable format for multiple containers. Each bundle can be deployed as a Stack at run-time in production.
  • 4. DAB in action - demo Front End Back End • Python webapp which lets you vote between several options • Node.js /AngularJS webapp showing the results of the poll in real time • Redis Queue to collect new votes • Java Worker which consumes votes and stores them in the database • Postgres database backed by a Docker Volume
  • 5. related command synopsis $ docker-compose bundle --help Generate a Distributed Application Bundle (DAB) from the Compose file . Images must have digests stored, which requires interaction with a Docker registry. If digests aren't stored for all images, you can fetch them with `docker-compose pull` or `docker- compose push`. To push images automatically when bundling, pass `--push-images`. Only services with a `build` option specified will have their images pushed. Usage: bundle [options] Options: --push-images Automatically push images for any services which have a `build` option specified. -o, --output PATH Path to write the bundle file to. Defaults to "<project name>.dab”. $ docker deploy --help Usage: docker deploy [OPTIONS] STACK Create and update a stack from a Distributed Application Bundle (DAB) Options: --file string Path to a Distributed Application Bundle file (Default: STACK.dab) --help Print usage --with-registry-auth Send registry authentication details to Swarm agents
  • 6. related command synopsis..cont $ docker stack --help Usage: docker stack COMMAND Manage Docker stacks Options: --help Print usage Commands: config Print the stack configuration deploy Create and update a stack from a Distributed Application Bundle (DAB) rm Remove the stack ps List the tasks in the stack
  • 7. Docker Compose vs DAB • Docker Compose is a client side tool presently used in development / test workflow • Docker DAB is ( specifically intended ) to be used at scale and server side orchestration within production environment. Bundle deployment is an integral function of docker 1.12 engine. Stack can be deployed on a docker 1.12 swarm cluster only. • DAB can deploy non-containerised app also. • more (?)
  • 8. Playbook : swarm/dab local test setup 1/4 • Pre-requisite : one Host PC or laptop : Windows 7+, MacOS X 10.11+, any modern Linux with 3.10+ kernel ( recommended, Redhat/Centos/Ubuntu) with min 4GB ( 8GB recomended) RAM and 20GB free hard disk. • For Windows and OSX, one can install docker toolbox from https://docs.docker.com/ toolbox/overview/. Additionally can install docker for windows or OSX client also. For Linux, install latest docker ver 1.12+ client /server , compose 1.8 from https:// docs.docker.com/engine/getstarted/step_one/ . Docker toolbox on OSX and Windows also installs Oracle Virtualbox ; for Linux install it from https://www.virtualbox.org/wiki/ Downloads • Create a docker hub/cloud login account ( https://cloud.docker.com/ - req only if one wish to build custom images and push/pull from docker hub repository) • Now we are ready to setup nodes and a swarm cluster on it • Note : This playbook is for local VM setup. One can alternatively spin up machines on any public cloud and follow this guide accordingly.
  • 9. We will setup a simple 3 node swarm with 1 leader (master ) using docker-machine Create the nodes : $ docker-machine create -d virtualbox master $ docker-machine create -d virtualbox node-1 $ docker-machine create -d virtualbox node-2 Inspect/configure the VM nodes created : $ docker-machine ls Note : VirtualBox will generally provision 2 networks : one NAT for internet and one Host-only networking whose IP will be dynamically allotted with each reboots. This changing DHCP IP allocation will break our docker PKI and swarm config on node reboots and hence the workaround presently is a tweak script here which can make this IP static ( Ref : https:// github.com/fivestars/docker-machine-ipconfig). Immediately after the VMs are created and docker provisioned - use the above docker-machine-ipconfig cmd and make these ips static. The other option is to bypass docker-machine and instead directly use vagrant/puppet/chef scripts with fixed ip declaration. Recommended ( not mandatory ) - Add the ip address for all 3 nodes from ‘docker-machine ls’ cmd above to /etc/hosts on the host OS machine. This playbook assumes such and refers nodes with their host name here viz. ( master , node-1 , node-2 ). Recommended to edit VM settings and set all the 3 node VMs memory to 1GB (min, recomended 2GB) each. Roll out the swarm cluster network : (Optional ) If docker for Windows or OSX client was also installed, then we need to point this local docker client to the Docker engine on master node by setting DOCKER_* environment variables using : $ eval $( docker-machine env master ) Lets initialise the swarm network on master node. $ docker-machine ssh master master $ docker swarm init — listen-addr=192.168.99.103:2733 —advertise-addr=192.168.99.103:2733 The - - advertise-addr above is required because of 2 network interface on these VMs. Substitute 192.168.99.103 above with your master node ip from ‘docker-machine ls’. The above command will return an URL with a swarm token string to be run on each worker nodes. SSH to each worker nodes and copy/paste this command on it $ docker-machine ssh node-1 node-1 $ ( copy/paste the above join command here ) repeat above for node-2. The docker swarm cluster is setup . Checkout the Docker swarm cluster members . PS: all commands further down are assumed to be run against master node. $ docker node ls This will show the three nodes with the elected leader node(s) tagged. Playbook : swarm/dab test-setup 2/4
  • 10. Test setup the classic voting app ( thanks to Docker ) Option -1 Download/ build the images required for this Docker playbook $ git clone https://github.com/docker/example-voting-app.git $ cd example-voting-app There are 5 services , one can modify the script to change the poll options etc. refer git read me. $ cd vote $ docker build --no-cache -t thomasch/votingapp_voting-app . { replace thomasch here in all the image name(s) with your docker-hub id or name } $ cd worker $ docker build --no-cache -t thomasch/votingapp_worker . $ cd result $ docker build --no-cache -t thomasch/votingapp_result-app . We will push these images to docker repository ( also create image digest ) $ docker login { provide docker hub/cloud username and password when prompted } $ docker push thomasch/votingapp_voting-app $ docker push thomasch/votingapp_worker $ docker push thomasch/votingapp_result-app { use corrected docker image names above } Option-2 OR ALTERNATIVELY instead of Option-1 , [ only if you trust them :) ] - you can pull these images directly from my docker public repository $ docker pull thomasch/votingapp_voting-app $ docker pull thomasch/votingapp_worker $ docker pull thomasch/votingapp_result-app Inspect the docker-compose.yml file in the example-voting-app folder. This file has to be slightly modified to be dab conversion compatible . Check/download the final edited version here : https://gist.github.com/thomgit/c0ddfcded35f986055e391442c83bda9 Copy this yml file to a new directory. Review and update the images names if you have changed them during custom build above in Option-1. Playbook : swarm/dab test-build 3/4
  • 11. Convert the compose YAML to DAB format and test stack and swarm workflow cd to the directory with modified docker-compose.yml file and covert this to .DAB format first pull the remaining images required for this voting app from public repository - redis, postgres $ docker-compose pull vote, redis, worker , db, result convert the docker-compose yaml file to JSON dab format using docker-compose client tool ( >ver 1.8 ) $ docker-compose bundle -o votingapp.dab. deploy this dab file on the swarm cluster we setup $ docker deploy votingapp This will deploy 5 services - it might take time for all the 5 services to start. Check the stack services status using $ docker stack ps votingapp Inspect the ‘PublishedPort’ for votingapp_vote and votingapp_result. These port(s) should be in 30000+ range. $ docker service inspect votingapp_vote --pretty $ docker service inspect votingapp_result --pretty The voting and results front-end will be available in the host machine browser on any ( swarm mesh network feature ) node cluster ip address ( e.g. http://192.168.99.xx: <PublshedPort> ). Test the vote page and see the real-time poll results displayed by the node.js/AngularJS result app page. We have stood-up an entire application stack now . The new ‘docker stack’ CLI can be used to manage all the services together in this stack: check the stack configuration $ docker stack config votingapp delete the entire stack $ docker stack rm votingapp Additional suggested activity Use this docker swarm cluster to : • test scale-up/down the votingapp_vote service • drain any one node and see how swarm reschedules the services to other node(s) to maintain the desired state of stack • create a new version of votingapp_vote_v2 and check out rolling upgrades. Hope this help get a reasonable grip on these exciting new docker 1.12 features... Playbook : swarm/dab test-run 3/4