SlideShare a Scribd company logo
DOCKER AND MICROSERVICE
What is this Docker and Microservice thing that everyone is talking about?
YOU BUILD IT, YOU RUN IT
“The best way to completely automate operations is to
have to developers be responsible for running the software
they develop. It is painful at times, but also means
considerable creativity gets applied to a very important
aspect of the software stack. It also brings developers into
direct contact with customers and a very effective feedback
loop starts. There is no separate operations department at
Amazon: you build it; you run it.
Werner Vogels, CTO Amazon – 2006
HOST ARCHITECTURE
How to run an application?
Infrastructure
• Can be a computer, cluster of computers, or the Cloud
• Abstract users from servers and infrastructure
• There’s a server but it’s hidden from you
SINGLE HOST
• Shared resources
• No user space (app) isolation
• Fairly tight coupling of
operating system and
applications
VIRTUAL MACHINE
• Better user space (app)
isolation
• Not very resource efficient
• Slower
• Guest OS can be different
from the host OS
CONTAINER VIRTUALIZER
• Better user space (app)
isolation
• Not as strong as that of
VM
• Lightweight
• Operating system
virtualization
• Base OS
WHAT IS DOCKER?
• Container = isolated (user
space) sandbox
• Docker = Container
implementation
• Benefits
• Lightweight
• Faster to launch
ISOLATED CONTAINERS
INFRASTRUCTURE AS CODE
Code your infrastructure
CONTAINER TECH
Existed for years in Linux
Docker (the company) just figured a clever way to
packaging it and adding a rich toolset around it.
DOCKER INTERNALS
• Docker runs on Linux x64 (only)
• Dependent on libcontainer, a Linux container platform
• Container isolation: filesystem, process, network
• Layered filesystem
• Benefits
• Versioning
• Portability
DOCKER WORKFLOW
Dockerfile
Docker Client
docker build
Image
Docker Client
docker run
Container
Docker Client
docker pull
docker push
Docker Registry
SAMPLE DOCKERFILE
FROM ubuntu:16.04
# Set up Redis
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install redis-server redis-
tools
# Run Redis and expose port
EXPOSE 6379
ENTRYPOINT [ "/usr/bin/redis-server" ]
CMD []
DOCKER IMAGE AND LAYERED
FILESYSTEM
• Docker image is a read-only template
and is used to create containers
• Docker image consists of filesystems
layered on top of each other
• Docker uses Union File Systems UFS to
build an image
• Any update to an image adds a new
layer instead of rebuilding the entire
image
• Container = images + top writable layer
• Images are shared across different
containers
BASE IMAGE SIZES
Reference: https://www.brianchristner.io/docker-image-base-os-size-comparison/
188 187
172
125
8 5 2
0
50
100
150
200
Ubuntu Fedora CentOS Debian Cirros Alpine BusyBox
6.50M
1.20M 1.20M
3.30M
.02M .04M
2.50M
.00M
1.00M
2.00M
3.00M
4.00M
5.00M
6.00M
7.00M
Ubuntu Fedora CentOS Debian Cirros Alpine BusyBox
Size (MB)
#
Download
s
(Popularity
)
DOCKER ON MAC AND WINDOWS
Running Docker on your Workstation
DOCKER ON MAC
• Let’s focus on running Docker on the Mac
• Remember Docker only runs on Linux x64
• How do I run it on the Mac?
• Need Virtual Machine to emulate a Linux host
• Virtual machine (VM) running Linux x64
• Docker engine running on VM
• Mac client to communicate with Docker engine on Linux VM
DOCKER FOR MAC VS DOCKER
TOOLBOX
Docker for Mac Docker Toolbox
# VMs 1 Multiple
Underlying VM
Hypervisor.framework
(xhyve)
VirtualBox
Base OS Alpine Boot2Docker
(VM) Management Tool Docker.app docker-machine
(VM) Management UI GUI CLI
MAC DOCKER ARCHITECTURE
DOWNLOAD
https://www.docker.com/products/docker-toolbox
https://docs.docker.com/docker-for-mac/
Or
$ brew cask install dockertoolbox
MULTI-CONTAINERS
Running multiple containers
USE CASE
• Web application running Ruby on Rails
• Common website root directory
• 1 Container running Ruby on Rails
• 1 Container running Nginx
• Connection to database
• 1 Container running Postgres
DOCKER VOLUME
• Volume can be created and mounted for more than 1 container to
share resources
• Put the website root folder in the volume
• Persist data
• Volume isn’t Union Filesystems, it exists as the host’s filesystem
DOCKER LINKING
• Docker linking relies on the Container names
• Launch your Docker container with names
• Link the 2 Docker containers via the parameter --link
• Docker establishes a secure tunnel between the container
• Does not expose any ports
• Does expose environment variables and /etc/hosts
DOCKER COMPOSE
• Before Compose there was Fig
• 1 configuration file = Compose file
• Use the configuration file to define and launch multiple Docker
containers
• It basically helps you to organize and configure your multiple Docker
container instances
DOCKER CLUSTERING TOOL
• There are some great tools that you can use to elegantly manage
multiple containers at scale
• Large scale coordination
• Service discovery
• Automatic failover
• Examples
• Swarm
• Kubernetes
• Mesos
MICROSERVICE
What is Microservice?
WHAT IS A MONOLITHIC SYSTEM
Reference: https://github.com/kbastani/spring-cloud-microservice-example
EXTENDING THE MONOLITHIC
Reference: https://github.com/kbastani/spring-cloud-microservice-example
MICROSERVICES
Reference: https://github.com/kbastani/spring-cloud-microservice-example
EXTENDING MICROSERVICES
Reference: https://github.com/kbastani/spring-cloud-microservice-example
DEMO
Tying together what we have learned so far
SPRING CLOUD MICROSERVICE
EXAMPLE
https://github.com/kbastani/spring-cloud-microservice-
example
PROJECT ORGANIZATION
• docker
• docker-compose.yml
• XXX-microservice
• src/main
• docker
• Dockerfile
• pom.xml
• pom.xml
MICROSERVICE DOCKERFILE
FROM java:8
VOLUME /tmp
ADD users-microservice-0.1.0.jar app.jar
RUN bash –c 'touch /app.jar'
EXPOSE 9000
ENTRYPOINT [ "java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
CLONE THE PROJECT
$ # Clone the project
$ git git@github.com:kbastani/spring-cloud-microservice-example.git
$ # Install prerequisites to build project
$ brew cask install java
$ brew install maven
RUN DOCKER-MACHINE ON LOCAL VM
$ # Launch Docker machine, set the VM RAM to 6GB
$ docker-machine create --driver virtualbox --virtualbox-memory 6144 default
$ docker-machine env
$ eval "$(docker-machine env default)"
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.12.0
RUN DOCKER-MACHINE ON AWS
$ # Launch Docker machine on AWS EC2
$ vi ~/.aws/credentials
$ cat ~/.aws/credentials
[default]
aws_access_key_id = AKIXXXXXXXXXXXXX
aws_secret_access_key =
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$ # Launch an AWS EC2 t2.large instance in us-west-2 zone
$ docker-machine create --driver amazonec2 --amazonec2-region us-west-2 --
amazonec2-instance-type t2.large docker-aws
BUILD
$ # Build Java application and Docker images
$ docker images
$ mvn clean install
$ docker images
$ cd docker
$ less docker-compose.yml # Take a peek at the compose config file
$ docker-compose up
TEST THE APPLICATIONS
$ # Run Eureka – API gateway/router
$ open $(echo "$(echo $DOCKER_HOST)"|
sed 's/tcp:///http:///g'|
sed 's/[0-9]{4,}/8761/g'|
sed 's/"//g')
$ # Run the movie API – this should register all the microservices
$ curl $(echo "$(echo $DOCKER_HOST)/movie"|
sed 's/tcp:///http:///g'|
sed 's/[0-9]{4,}/10000/g'|
sed 's/"//g')
DOCKER IS A
DEPLOYABLE UNIT
You build it, you run it with Docker. Developer now has the freedom to develop
and deploy services.
Q + A
Any questions?
You can find me at
@cybersam
REFERENCE
• Docker Toolbox -
https://www.docker.com/products/docker-toolbox
• Docker Documentation - https://docs.docker.com/
• Pros and Cons of Microservices -
https://smartbear.com/learn/api-design/what-are-
microservices/
• Spring Cloud Microservice Example -
https://github.com/kbastani/spring-cloud-microservice-
example
CREDITS
• Based on the Quintus template on Slides Carnival -
http://www.slidescarnival.com/quintus-free-presentation-
template/1405

More Related Content

PPSX
Big Data Redis Mongodb Dynamodb Sharding
PPT
Docker introduction
PDF
Mastering Azure Monitor
PPTX
Azure key vault
PPTX
k8s practice 2023.pptx
PPTX
Azure kubernetes service (aks)
PDF
Helm - Application deployment management for Kubernetes
PDF
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
Big Data Redis Mongodb Dynamodb Sharding
Docker introduction
Mastering Azure Monitor
Azure key vault
k8s practice 2023.pptx
Azure kubernetes service (aks)
Helm - Application deployment management for Kubernetes
Kubernetes Concepts And Architecture Powerpoint Presentation Slides

What's hot (20)

PDF
GCP CloudRun Overview
PDF
마이크로서비스 기반 클라우드 아키텍처 구성 모범 사례 - 윤석찬 (AWS 테크에반젤리스트)
PPTX
Microservice architecture design principles
PPTX
Let's Talk About: Azure Networking
PDF
Introduction to kubernetes
ODP
Kubernetes Architecture
PPTX
Google cloud platform
PPTX
Azure Introduction
PPSX
Microservices Docker Kubernetes Istio Kanban DevOps SRE
PPTX
Microsoft Azure cloud services
PPTX
Jenkins tutorial
PPTX
Introduction to Azure monitor
PPTX
An introduction to Serverless
PDF
Microservices with Java, Spring Boot and Spring Cloud
PDF
What Is Spring?
PPTX
Azure: PaaS or IaaS
PPTX
Multi tenancy - Wining formula for a PaaS
PPTX
Azure Network Security Groups (NSG)
PPTX
Cloud computing by Google Cloud Platform - Presentation
GCP CloudRun Overview
마이크로서비스 기반 클라우드 아키텍처 구성 모범 사례 - 윤석찬 (AWS 테크에반젤리스트)
Microservice architecture design principles
Let's Talk About: Azure Networking
Introduction to kubernetes
Kubernetes Architecture
Google cloud platform
Azure Introduction
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microsoft Azure cloud services
Jenkins tutorial
Introduction to Azure monitor
An introduction to Serverless
Microservices with Java, Spring Boot and Spring Cloud
What Is Spring?
Azure: PaaS or IaaS
Multi tenancy - Wining formula for a PaaS
Azure Network Security Groups (NSG)
Cloud computing by Google Cloud Platform - Presentation
Ad

Viewers also liked (20)

PPTX
Mobile Analytics
PPTX
moscmy2016: Extending Docker
PDF
georchestra SDI: Project Status Report
PDF
Deploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
PPTX
Service Orchestrierung mit Apache Mesos
PDF
How to Build Cloud-based Microservice Environments with Docker and VoltDB
PPT
TransitioningToMicroServonDocker_MS
PDF
Introduction to Docker - Learning containerization XP conference 2016
PDF
Using docker to develop NAS applications
PPTX
Containers for sensor web services, applications and research @ Sensor Web Co...
PDF
Docker for the Brave
PPTX
Hybrid Mobile Development with Apache Cordova and
PDF
MicroService and MicroContainer with Apache Camel
PDF
Docker Dhahran Nov 2016 meetup
PDF
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
PDF
Cordova / PhoneGap, mobile apps development with HTML5/JS/CSS
PPTX
2015 03-11_todd-fritz_devnexus_2015
PPTX
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
PPTX
Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
PDF
Dockerize node.js application
Mobile Analytics
moscmy2016: Extending Docker
georchestra SDI: Project Status Report
Deploying 3 times a day without a downtime @ Rocket Tech Summit in Berlin
Service Orchestrierung mit Apache Mesos
How to Build Cloud-based Microservice Environments with Docker and VoltDB
TransitioningToMicroServonDocker_MS
Introduction to Docker - Learning containerization XP conference 2016
Using docker to develop NAS applications
Containers for sensor web services, applications and research @ Sensor Web Co...
Docker for the Brave
Hybrid Mobile Development with Apache Cordova and
MicroService and MicroContainer with Apache Camel
Docker Dhahran Nov 2016 meetup
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Cordova / PhoneGap, mobile apps development with HTML5/JS/CSS
2015 03-11_todd-fritz_devnexus_2015
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
Dockerize node.js application
Ad

Similar to Docker and Microservice (20)

PPTX
Microservices in academic environment
PDF
Thomas Rossetto - Container and microservices: a love story - Codemotion Mila...
PDF
Container and microservices: a love story
PPTX
Docker Introduction
PDF
Containers and Nutanix - Acropolis Container Services
PPTX
Introduction Into Docker Ecosystem
PDF
Demystifying Docker
PPTX
Demystifying Docker101
PDF
Docker 0.11 at MaxCDN meetup in Los Angeles
PDF
Docker what - Frank Maounis
PPTX
Microservices and containers for the unitiated
PPTX
Real World Experience of Running Docker in Development and Production
PDF
Dockers and kubernetes
PDF
Agile Brown Bag - Vagrant & Docker: Introduction
PPTX
Containerization using docker and its applications
PPTX
Containerization using docker and its applications
PDF
Introduction to Docker - VIT Campus
PPTX
ma-formation-en-Docker-jlklk,nknkjn.pptx
PDF
An Introduction To Docker
PPTX
The challenge of application distribution - Introduction to Docker (2014 dec ...
Microservices in academic environment
Thomas Rossetto - Container and microservices: a love story - Codemotion Mila...
Container and microservices: a love story
Docker Introduction
Containers and Nutanix - Acropolis Container Services
Introduction Into Docker Ecosystem
Demystifying Docker
Demystifying Docker101
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker what - Frank Maounis
Microservices and containers for the unitiated
Real World Experience of Running Docker in Development and Production
Dockers and kubernetes
Agile Brown Bag - Vagrant & Docker: Introduction
Containerization using docker and its applications
Containerization using docker and its applications
Introduction to Docker - VIT Campus
ma-formation-en-Docker-jlklk,nknkjn.pptx
An Introduction To Docker
The challenge of application distribution - Introduction to Docker (2014 dec ...

More from Samuel Chow (8)

PDF
Docker primer and tips
PDF
Terraforming your Infrastructure on GCP
PDF
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
PDF
Docker, Kubernetes, and Google Cloud
PPTX
UI Design - Lessons Learned, Principles, and Best Practices
PPTX
iOS Release Management
PDF
Frisbee Thrower Prototype
PDF
Frisbee Thrower Concepts (Part 1)
Docker primer and tips
Terraforming your Infrastructure on GCP
GCPLA Meetup Workshop - Migration from a Legacy Infrastructure to the Cloud
Docker, Kubernetes, and Google Cloud
UI Design - Lessons Learned, Principles, and Best Practices
iOS Release Management
Frisbee Thrower Prototype
Frisbee Thrower Concepts (Part 1)

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
medical staffing services at VALiNTRY
PPT
Introduction Database Management System for Course Database
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Odoo POS Development Services by CandidRoot Solutions
ISO 45001 Occupational Health and Safety Management System
Odoo Companies in India – Driving Business Transformation.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Which alternative to Crystal Reports is best for small or large businesses.pdf
medical staffing services at VALiNTRY
Introduction Database Management System for Course Database
PTS Company Brochure 2025 (1).pdf.......
Design an Analysis of Algorithms II-SECS-1021-03
Wondershare Filmora 15 Crack With Activation Key [2025
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
How to Choose the Right IT Partner for Your Business in Malaysia
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...

Docker and Microservice

  • 1. DOCKER AND MICROSERVICE What is this Docker and Microservice thing that everyone is talking about?
  • 2. YOU BUILD IT, YOU RUN IT “The best way to completely automate operations is to have to developers be responsible for running the software they develop. It is painful at times, but also means considerable creativity gets applied to a very important aspect of the software stack. It also brings developers into direct contact with customers and a very effective feedback loop starts. There is no separate operations department at Amazon: you build it; you run it. Werner Vogels, CTO Amazon – 2006
  • 3. HOST ARCHITECTURE How to run an application?
  • 4. Infrastructure • Can be a computer, cluster of computers, or the Cloud • Abstract users from servers and infrastructure • There’s a server but it’s hidden from you
  • 5. SINGLE HOST • Shared resources • No user space (app) isolation • Fairly tight coupling of operating system and applications
  • 6. VIRTUAL MACHINE • Better user space (app) isolation • Not very resource efficient • Slower • Guest OS can be different from the host OS
  • 7. CONTAINER VIRTUALIZER • Better user space (app) isolation • Not as strong as that of VM • Lightweight • Operating system virtualization • Base OS
  • 8. WHAT IS DOCKER? • Container = isolated (user space) sandbox • Docker = Container implementation • Benefits • Lightweight • Faster to launch
  • 10. INFRASTRUCTURE AS CODE Code your infrastructure
  • 11. CONTAINER TECH Existed for years in Linux
  • 12. Docker (the company) just figured a clever way to packaging it and adding a rich toolset around it.
  • 13. DOCKER INTERNALS • Docker runs on Linux x64 (only) • Dependent on libcontainer, a Linux container platform • Container isolation: filesystem, process, network • Layered filesystem • Benefits • Versioning • Portability
  • 14. DOCKER WORKFLOW Dockerfile Docker Client docker build Image Docker Client docker run Container Docker Client docker pull docker push Docker Registry
  • 15. SAMPLE DOCKERFILE FROM ubuntu:16.04 # Set up Redis RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get -y install redis-server redis- tools # Run Redis and expose port EXPOSE 6379 ENTRYPOINT [ "/usr/bin/redis-server" ] CMD []
  • 16. DOCKER IMAGE AND LAYERED FILESYSTEM • Docker image is a read-only template and is used to create containers • Docker image consists of filesystems layered on top of each other • Docker uses Union File Systems UFS to build an image • Any update to an image adds a new layer instead of rebuilding the entire image • Container = images + top writable layer • Images are shared across different containers
  • 17. BASE IMAGE SIZES Reference: https://www.brianchristner.io/docker-image-base-os-size-comparison/ 188 187 172 125 8 5 2 0 50 100 150 200 Ubuntu Fedora CentOS Debian Cirros Alpine BusyBox 6.50M 1.20M 1.20M 3.30M .02M .04M 2.50M .00M 1.00M 2.00M 3.00M 4.00M 5.00M 6.00M 7.00M Ubuntu Fedora CentOS Debian Cirros Alpine BusyBox Size (MB) # Download s (Popularity )
  • 18. DOCKER ON MAC AND WINDOWS Running Docker on your Workstation
  • 19. DOCKER ON MAC • Let’s focus on running Docker on the Mac • Remember Docker only runs on Linux x64 • How do I run it on the Mac? • Need Virtual Machine to emulate a Linux host • Virtual machine (VM) running Linux x64 • Docker engine running on VM • Mac client to communicate with Docker engine on Linux VM
  • 20. DOCKER FOR MAC VS DOCKER TOOLBOX Docker for Mac Docker Toolbox # VMs 1 Multiple Underlying VM Hypervisor.framework (xhyve) VirtualBox Base OS Alpine Boot2Docker (VM) Management Tool Docker.app docker-machine (VM) Management UI GUI CLI
  • 24. USE CASE • Web application running Ruby on Rails • Common website root directory • 1 Container running Ruby on Rails • 1 Container running Nginx • Connection to database • 1 Container running Postgres
  • 25. DOCKER VOLUME • Volume can be created and mounted for more than 1 container to share resources • Put the website root folder in the volume • Persist data • Volume isn’t Union Filesystems, it exists as the host’s filesystem
  • 26. DOCKER LINKING • Docker linking relies on the Container names • Launch your Docker container with names • Link the 2 Docker containers via the parameter --link • Docker establishes a secure tunnel between the container • Does not expose any ports • Does expose environment variables and /etc/hosts
  • 27. DOCKER COMPOSE • Before Compose there was Fig • 1 configuration file = Compose file • Use the configuration file to define and launch multiple Docker containers • It basically helps you to organize and configure your multiple Docker container instances
  • 28. DOCKER CLUSTERING TOOL • There are some great tools that you can use to elegantly manage multiple containers at scale • Large scale coordination • Service discovery • Automatic failover • Examples • Swarm • Kubernetes • Mesos
  • 30. WHAT IS A MONOLITHIC SYSTEM Reference: https://github.com/kbastani/spring-cloud-microservice-example
  • 31. EXTENDING THE MONOLITHIC Reference: https://github.com/kbastani/spring-cloud-microservice-example
  • 34. DEMO Tying together what we have learned so far
  • 36. PROJECT ORGANIZATION • docker • docker-compose.yml • XXX-microservice • src/main • docker • Dockerfile • pom.xml • pom.xml
  • 37. MICROSERVICE DOCKERFILE FROM java:8 VOLUME /tmp ADD users-microservice-0.1.0.jar app.jar RUN bash –c 'touch /app.jar' EXPOSE 9000 ENTRYPOINT [ "java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  • 38. CLONE THE PROJECT $ # Clone the project $ git git@github.com:kbastani/spring-cloud-microservice-example.git $ # Install prerequisites to build project $ brew cask install java $ brew install maven
  • 39. RUN DOCKER-MACHINE ON LOCAL VM $ # Launch Docker machine, set the VM RAM to 6GB $ docker-machine create --driver virtualbox --virtualbox-memory 6144 default $ docker-machine env $ eval "$(docker-machine env default)" $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * virtualbox Running tcp://192.168.99.100:2376 v1.12.0
  • 40. RUN DOCKER-MACHINE ON AWS $ # Launch Docker machine on AWS EC2 $ vi ~/.aws/credentials $ cat ~/.aws/credentials [default] aws_access_key_id = AKIXXXXXXXXXXXXX aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $ # Launch an AWS EC2 t2.large instance in us-west-2 zone $ docker-machine create --driver amazonec2 --amazonec2-region us-west-2 -- amazonec2-instance-type t2.large docker-aws
  • 41. BUILD $ # Build Java application and Docker images $ docker images $ mvn clean install $ docker images $ cd docker $ less docker-compose.yml # Take a peek at the compose config file $ docker-compose up
  • 42. TEST THE APPLICATIONS $ # Run Eureka – API gateway/router $ open $(echo "$(echo $DOCKER_HOST)"| sed 's/tcp:///http:///g'| sed 's/[0-9]{4,}/8761/g'| sed 's/"//g') $ # Run the movie API – this should register all the microservices $ curl $(echo "$(echo $DOCKER_HOST)/movie"| sed 's/tcp:///http:///g'| sed 's/[0-9]{4,}/10000/g'| sed 's/"//g')
  • 43. DOCKER IS A DEPLOYABLE UNIT You build it, you run it with Docker. Developer now has the freedom to develop and deploy services.
  • 44. Q + A Any questions? You can find me at @cybersam
  • 45. REFERENCE • Docker Toolbox - https://www.docker.com/products/docker-toolbox • Docker Documentation - https://docs.docker.com/ • Pros and Cons of Microservices - https://smartbear.com/learn/api-design/what-are- microservices/ • Spring Cloud Microservice Example - https://github.com/kbastani/spring-cloud-microservice- example
  • 46. CREDITS • Based on the Quintus template on Slides Carnival - http://www.slidescarnival.com/quintus-free-presentation- template/1405

Editor's Notes

  • #4: Let’s start with the basics!
  • #5: When I took the course Operating System, we learned the term hardware. Since then the industry has changed and what was called hardware then has now been abstracted to be known as infrastructure, which covers hardware, cluster of nodes, and the Cloud. In general the 4 key abstraction layers of running an application are: Application Operating System Kernel Infrastructure The following are the 3 basic hosting models.
  • #7: In a virtual machine, the guest OS and host OS run in own kernel and the guest OS communicates with the actual infrastructure through the hypervisor. This mode is usually slower and due to hardware emulation.
  • #8: In this virtualization mode, multiple isolated user space instance runs on the same kernel. These isolated user space are containers and they share the host kernel. Essentially Docker uses resource isolation feature of the Linux kernel eg. cgroups and kernel namespaces to allow containers to run within a single Linux instance.
  • #9: Docker is an implementation of Container.
  • #12: Google has been using their own container for years. In Open-source land, Linux has LXC and Libcontainer, BSD has jails, Solaris has Zones.
  • #14: Before we jump to code, it would be good to understand the internals of Docker. This way we can understand how Docker code gets executed in a Docker Container.
  • #15: To use docker all you need are these 4 commands: docker build docker pull docker push docker run
  • #17: Namespace provides the container a view of the underlying system. Network Process ID Mount User Cgroup manages the resources eg. CPU, memory, network Union file system (UFS) Benefits of UFS Avoid duplicating a layer Incremental addition to the image via layer
  • #20: Due to the time constraint, let’s focus on the Mac. It used to be a pain to get Docker working on the Mac. Things have improved but it can still be confusing. I hope to help you navigate through the Docker ecosystem on the Mac.
  • #21: The key difference between the 2 is how you manage your VM. Both Docker for Mac and Docker Toolbox can coexist. But verdict is still out there. I would say try using one of the solutions for now. Docker for Mac is seamless, you launch Docker.app from the GUI and you run your docker client just like you would on a Linux host.
  • #22: Let’s talk about running Docker on the Mac. To run Docker you need Docker toolbox. Because we need to Linux to run Docker, we need to launch Linux virtual machines from which we load Docker containers. Good news is that Docker (the company) makes all this easy. Doocker toolbox is based on boot2docker, which is 1 part Linux distro that the VM will load to run Docker and 1 part management tool. Boot2Docker Linux distro is super light and uses ~27MB and boots in 5s.
  • #25: Here’s a good use case. There are applications that may consist of multiple containers. Here is a good use case: a Rails web application. We have 1 container running Rails and another container running nginx. But the files that the 2 containers use are shared and need to be in a common root directory.
  • #27: Through Docker Volume, you share resources between multiple containers. But what if you need a container to communicate with another container? This is where Docker Link comes in. Run your Docker container with a name – names are unique. Eg. docker run –d –P –name web training/webapp python app.py Run a docker and link it to the other container Note: There’s also port mapping that Docker containers can use to connect to one another.
  • #28: Running multiple Docker containers can get hairy pretty quickly. Beyond just sharing of files in a common Volume, there’s automated configuration, coordination, and management of service. So enter Docker orchestration tools that can help you to manage and run multiple Docker containers in a single host or a cluster of thousand nodes. Fig was an open source Docker orchestration tool developed by Orchard before it got acquired by Docker. The tool has been refined and released as Compose.
  • #33: Decompose software down into multiple component services Message-based communication Decentralized data management – service manages its unique database Smart end points and dumb pipes
  • #34: Datasets are often joined. For example, a user rates a movie, a movie is rated by a user, a user follows another user. The data relationships transcend the physical database. In a microservice environment, one of the most common way to resolve this issue is by having an service A to call another service B.
  • #37: Running multiple containers in a single host is hard, try doing that in a cluster
  • #39: Running multiple containers in a single host is hard, try doing that in a cluster
  • #40: Running multiple containers in a single host is hard, try doing that in a cluster
  • #41: Running multiple containers in a single host is hard, try doing that in a cluster
  • #42: Running multiple containers in a single host is hard, try doing that in a cluster
  • #43: Running multiple containers in a single host is hard, try doing that in a cluster
  • #44: Remember the statement you heard at the beginning of the presentation? You build it; you run it