Dockerize it all

62
www.tothenew.com Dockerize it all

Transcript of Dockerize it all

Page 1: Dockerize it all

www.tothenew.com

Dockerize it all

Puneet Behl
Remove this slide
Puneet Behl
Updated definition of Docker Container, I think may be we don't need it as we could have Docker architecture here [email protected] what are your thoughts?
Puneet Behl
Need to be removed
Puneet Behl
[email protected] First let's explain why do we need this? and then show the Dockerfile
Puneet Behl
[email protected] Write an use-case with image
Page 2: Dockerize it all

www.tothenew.com

About Me

Puneet BehlAssociate Technical LeadTO THE NEW [email protected]: https://github.com/puneetbehl/Twitter: @puneetbhlLinkedIn: https://in.linkedin.com/in/puneetbhl

Page 3: Dockerize it all

www.tothenew.com

Agenda

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello world demo● Running Stack of services using Docker Compose● Moving to Production

Page 4: Dockerize it all

www.tothenew.com

Agenda

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello world demo● Running Stack of services using Docker Compose● Moving to Production

Page 5: Dockerize it all

www.tothenew.com

Let’s see how things can get complicated with shipping code??

Page 6: Dockerize it all

www.tothenew.com

A simple web application with one developer

A Developer

Page 7: Dockerize it all

www.tothenew.com

Added more developers to team

Multiple Developers

Page 8: Dockerize it all

www.tothenew.com

Setup QA & Production Environment

Multiple Developers

QA ServerPublic Cloud

Production Clusters

Page 9: Dockerize it all

www.tothenew.com

Created Background Workers

Multiple Developers

QA ServerPublic Cloud

Production Clusters

Page 10: Dockerize it all

www.tothenew.com

Refactored, Microservice Architecture

Multiple Developers

QA ServerPublic Cloud

Production Clusters

Page 11: Dockerize it all

www.tothenew.com

● “Works on my machine” syndrome● Hard disk crashed -> New Setup -> Nothing Works :(● Adding new Developer in the team● Going live? Please DO NOT break on production.● Dependency Hell - Common dependency with different

versions

In Nutshell, what are the challenges?

Page 12: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Understanding Docker components & architecture.● Installation● Hello World demo● Running Stack of services using Docker Compose● Moving to Production

Page 13: Dockerize it all

www.tothenew.com

The Solution

Multiple Developers

QA ServerPublic Cloud

Production Clusters

Page 14: Dockerize it all

www.tothenew.com

The Solution, Contd...

Multiple Developers

QA ServerPublic Cloud

Production Clusters

Page 15: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello World demo● Running Stack of services using Docker Compose● Moving to Production

Page 16: Dockerize it all

www.tothenew.com

A Docker Container allows application developer to package up their application with all it’s dependencies they are associated with.

What is Docker Container?

Page 17: Dockerize it all

www.tothenew.com

Okay! I understand Docker Containers now, they are like VM???

Page 18: Dockerize it all

www.tothenew.com

Okay! I understand Docker Containers now, they are like VM???

Page 19: Dockerize it all

www.tothenew.com

Hmmm…

Page 20: Dockerize it all

www.tothenew.com

Let’s see what is the difference between application running on VM v/s Docker?

Page 21: Dockerize it all

www.tothenew.com

Application Running On VM v/s Container

Page 22: Dockerize it all

www.tothenew.com

Application Running On Docker Container

Page 23: Dockerize it all

www.tothenew.com

Application Running On VM v/s Container

Page 24: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello World demo● Running Stack of services using Docker Compose● Moving to Production

Page 25: Dockerize it all

www.tothenew.com

● Scalability - The containers are extremely lightweight so scaling up and scaling down is very easy.

Benefits of using Docker

Page 26: Dockerize it all

www.tothenew.com

● Scalability - The containers are extremely lightweight so scaling up and scaling down is very easy.

● Portability - just pull the image and start container.

Benefits of using Docker

Page 27: Dockerize it all

www.tothenew.com

● Scalability - The containers are extremely lightweight so scaling up and scaling down is very easy.

● Portability - just pull the image and start container.● Deployment - because containers can run almost anywhere

we can deploy to Desktop, Physical Server, Virtual Machine, Public/Private Cloud etc.

Benefits of using Docker

Page 28: Dockerize it all

www.tothenew.com

● Scalability - The containers are extremely lightweight so scaling up and scaling down is very easy.

● Portability - just pull the image and start container.● Deployment - because containers can run almost anywhere

we can deploy to Desktop, Physical Server, Virtual Machine, Public/Private Cloud etc.

● Efficient Resource Utilization - Multiple isolated containers sharing resources.

Benefits of using Docker

Page 29: Dockerize it all

www.tothenew.com

Why Developers Care?

Page 30: Dockerize it all

www.tothenew.com

● Build any application in any language using any stack.● Dockerize application can run anywhere on anything.● No longer need to cross our fingers when we deploy to

production● Helps improving application design

Why Developers Care?

Page 31: Dockerize it all

www.tothenew.com

Why Devops Care?

Page 32: Dockerize it all

www.tothenew.com

● Easy migrations to different infrastructure● Replication of different environments is very easy.● Fix an issue once, it’s fixed everywhere ● Less conflicts with developers, because of same

environment.

Why Devops Care?

Page 33: Dockerize it all

www.tothenew.com

Why Business Care?

Page 34: Dockerize it all

www.tothenew.com

● Boost Productivity

Why Business Care?

Page 35: Dockerize it all

www.tothenew.com

● Boost Productivity● Reduce Risk

Why Business Care?

Page 36: Dockerize it all

www.tothenew.com

● Boost Productivity● Reduce Risk● Reduce Cost

Why Business Care?

Page 37: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello World demo...● Running Stack of services using Docker Compose● Moving to Production

Page 38: Dockerize it all

www.tothenew.com

Docker Core Components

● Docker Daemon

Page 39: Dockerize it all

www.tothenew.com

Docker Core Components

● Docker DaemonThe Docker daemon runs on a host machine. The user does not directly interact with the daemon, but instead through the Docker client.

Page 40: Dockerize it all

www.tothenew.com

Docker Core Components

● Docker Daemon

● Docker Client

Page 41: Dockerize it all

www.tothenew.com

Docker Core Components

● Docker Daemon

● Docker ClientThe Docker client, in the form of the docker binary, is the primary user interface to Docker. It accepts commands from the user and communicates back and forth with a Docker daemon.

Page 42: Dockerize it all

www.tothenew.com

Docker Workflow Components

Page 43: Dockerize it all

www.tothenew.com

Docker Workflow Components

● Docker ImageA Docker image is a read-only template to build Docker Containers

Page 44: Dockerize it all

www.tothenew.com

Docker Workflow Components

● Docker ImageA Docker image is a read-only template to build Docker Containers

● Docker RegistriesDocker registries hold images. These are public or private stores from where you upload or download images.

Page 45: Dockerize it all

www.tothenew.com

Docker Workflow Components

● Docker ImageA Docker image is a read-only template to build Docker Containers

● Docker ContainerCreated from images. start, stop, run

● Docker RegistriesDocker registries hold images. These are public or private stores from where you upload or download images.

Page 46: Dockerize it all

www.tothenew.com

Docker Architecture

Page 47: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello World demo● Running Stack of services using Docker Compose● Moving to Production

Page 48: Dockerize it all

www.tothenew.com

Installation

● Linux Follow steps for your version of linux https://docs.docker.com/engine/installation/

apt-get install docker-engine

yum install docker-engine

● Mac or Windows OS Use docker toolbox isntaller : https://www.docker.com/docker-toolbox

Page 49: Dockerize it all

www.tothenew.com

Installations : Docker toolbox

Page 50: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello world demo● Running Stack of services using Docker Compose● Moving to Production

Page 51: Dockerize it all

www.tothenew.com

A Spring Boot application

$ ( spring jar hello.jar hello.groovy ) && ( java -jar hello.jar )

Page 52: Dockerize it all

www.tothenew.com

Build Image Using Dockerfile

FROM java:8

MAINTAINER Puneet Behl "[email protected]"

ADD hello.jar /app/hello.jar

EXPOSE 8080

CMD ["java", "-jar", "/app/hello.jar"]

Page 53: Dockerize it all

www.tothenew.com

Build Docker image and push to Docker Hub

Page 54: Dockerize it all

www.tothenew.com

Contents

● Understanding the problem of shipping code● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello world demo● Running stack of services using Docker compose● Moving to Production

Page 55: Dockerize it all

www.tothenew.com

A Complicated application architecture

Page 56: Dockerize it all

www.tothenew.com

Docker Compose

frontend: image: pbehl/frontend ports: - "3000:3000" links: - backend environment: backendServerUrl: "http://backend:8080" command: "node server.js"

mongodb: image: mongobackend: image: pbehl/backend links: - mongodb environment: "spring.data.mongodb.host": "mongodb" "logging.level.org.springframework.web": "DEBUG" ports: - "8080:8080"

Page 57: Dockerize it all

www.tothenew.com

Build using Docker Compose

Page 58: Dockerize it all

www.tothenew.com

Contents

● Understand the problem● The solution● What is Docker Container?● Benefits of Docker● Understanding Docker components & architecture.● Installation● Hello world demo● Running Stack of services using Docker Compose● Moving to Production

Page 59: Dockerize it all

www.tothenew.com

Orchestration tools needed for docker cluster environment● Provision servers● Deploy● Manage servers

Some of the available orchestration tools● Docker swarm● Centurion● Amazon EC2 container service

Moving to Production

Page 60: Dockerize it all

www.tothenew.com

Questions???

Page 61: Dockerize it all

www.tothenew.com

Thank you

Page 62: Dockerize it all

www.tothenew.com

Sample Demo: https://github.com/puneetbehl/gr8conf-docker-demoDocker documentation: https://docs.docker.comDocker tool-box https://www.docker.com/docker-toolboxDocker hub: https://hub.docker.com/Docker up and running from O'Reilly publication Authors: Karl Matthias & Sean P. KaneUnion file system : https://en.wikipedia.org/wiki/UnionFShttp://stackoverflow.com/questions/16047306/how-is-docker-different-from-a-normal-virtual-machineBuild and push images to docker hub https://youtu.be/QCEWQs6LwAkDocker-compose https://youtu.be/kn_dUA6f29I

References