Intro Docker Containers
Intro Docker Containers
• Microservices
https://martinfowler.com/articles/microservices.html
The Challenge
User DB
Do services and
appropriately?
apps interact
Static website postgresql + pgv8 + v8
Multiplicity of
Queue Analytics DB
nginx 1.5 + modsecurity + openssl
hadoop + hive + thrift + OpenJDK
Stacks
Web frontend
Background workers
Ruby + Rails + sass + Unicorn
Python 3.0 + celery + pyredis + libcurl +
ffmpeg + libopencv + nodejs + phantomjs API endpoint
Python 2.7 + Flask + pyredis + celery +
psycopg + postgresql-client
Production Cluster
environments
Development VM
Multiplicity of
Public Cloud
smoothly and
Can I migrate
hardware
quickly?
QA server
Disaster recovery
Customer Data Center Contributor’s laptop
Production Servers
Results in N X N compatibility nightmare
Static website ? ? ? ? ? ? ?
Web frontend ? ? ? ? ? ? ?
Background ? ? ? ? ? ? ?
workers
User DB ? ? ? ? ? ? ?
Analytics DB ? ? ? ? ? ? ?
Queue ? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Solution: Shipping Container
spices)
A standard container
that is loaded with
virtually any goods,
and stays sealed until
it reaches final
delivery.
…in between, can be
loaded and unloaded,
stacked, transported
Can I transport
distances, and
to truck)
transferred from one
for
mode of transport to
another
This eliminated the NXN problem…
• 90% of all cargo now shipped in a standard container
• Order of magnitude reduction in cost and time to load and
unload ships
• Massive reduction in losses due to theft or damage
• Huge reduction in freight cost as percent of final goods (from
>25% to <3%)
massive globalizations
• 5000 ships deliver 200M containers per year
Docker is a shipping container system for code
Analytics DB
appropriately?
interact
An engine that
enables any payload
to be encapsulated
as a lightweight,
portable, self-
sufficient
container…
…that can be
manipulated using
Can I migrate
run consistently on
virtually any hardware
platform
appropriately?
interact
Developer: Build
Once, Run Anywhere
(Finally)
Operator: Configure
Once, Run Anything
Can I migrate
Develop QA server Customer Public Cloud Production Contributo
ment VM Data Center Cluster r’s laptop
Docker solves the NXN problem
Static website
Web frontend
Background
workers
User DB
Analytics DB
Queue
○ Load balancing: The ability to automatically distribute incoming traffic across multiple
containers.
○ Service discovery: The ability to automatically discover and connect to other services in
the system.
Docker Swarm
● Docker Swarm is a native clustering and orchestration
solution for Docker.
● It allows you to create and manage a cluster of Docker
nodes as a single virtual system.
● It provides features such as service discovery, load
balancing, and scaling, which makes it easy to build,
ship and run distributed applications.
● It also allows you to schedule the placement of
containers across the nodes in the cluster, and to ensure
that the desired number of replicas of a container are
running at all times.
Kubernetes
● Kubernetes (often shortened to "K8s") is an open-source container orchestration
system that automates the deployment, scaling, and management of containerized
applications.
● It was originally developed by Google and is now maintained by the Cloud Native
Computing Foundation (CNCF).
● Kubernetes manage containerized applications in a clustered environment. It
abstracts away the underlying infrastructure and provides a consistent set of APIs
for deploying, scaling, and managing containerized applications.
● Kubernetes uses a declarative configuration model, where the desired state of the
system is defined in configuration files.
● The declarative configuration model is a way of describing the desired state of a
system, rather than the steps needed to achieve that state.
● This approach allows administrators to specify the desired state of their applications
and infrastructure, and then rely on Kubernetes to automatically make the
necessary changes to achieve that state.
Kubernetes (Cont.)
•Kubernetes provides several key features:
1. Kubernetes is an open-source platform that was originally developed by Google and is now maintained by
the Cloud Native Computing Foundation (CNCF). Docker Swarm, on the other hand, is a native clustering
and orchestration solution for Docker.
2. Kubernetes provides a more powerful and flexible orchestration engine, with more advanced features such
as automatic scaling, self-healing, and rollouts, and rollbacks. Docker Swarm is more limited in terms of its
orchestration capabilities, but it is simpler to set up and use.
3. Kubernetes provides a declarative configuration model where the desired state of the system is defined in
configuration files, while Docker Swarm uses a more imperative model where the desired state is defined
through commands.
4. Kubernetes supports a wide range of deployment options including on-premise, in the public cloud, and
hybrid deployments. Docker Swarm is typically used for deployments on a single cluster or a single cloud
provider.
5. Kubernetes has a large and active community, with many contributors and a wide range of third-party tools
and plugins available. Docker Swarm has a smaller community and fewer third-party tools and plugins.
6. Kubernetes is more complex to set up and manage, it is typically used for large-scale production
deployments, while Docker Swarm is simpler and more suited for small-scale and development
deployments.
Microservice Architecture
“Microservice architectural is an approach to developing a
single application as a suite of small services, each
running in its own process and communicating with
lightweight mechanisms, often an HTTP resource API.
These services are built around business capabilities and
independently deployable by fully automated deployment
machinery.”
Microservice Architecture (cont.)
Traditional development
Microservices Architecture
Coming up next!
Working with Docker . . .