Top Banner
Jumpstarting Docker Arup Nanda VP, Data Services Priceline.com
38

Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Apr 20, 2019

Download

Documents

hoangduong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Jumpstarting DockerArup Nanda

VP, Data ServicesPriceline.com

Page 2: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Docker for Oracle2

My application worked in Dev but not in QAWill it work in production?

I need an environment right nowNo, I can’t wait for 2 weeks

I just need it for a day to test my hypothesis. What do you mean I should have budgeted it?.

Page 3: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Docker for Oracle3

booking.com|priceline.com|kayak.com|agoda.com|rentalcars.com|opentable.com

Page 4: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Demand SupplyTechnologyBots

Docker for Oracle4

Page 5: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Demand SupplyTechnology

WWW

Affiliates

White labels

Providers

GDS

Affiliates

Inventory250K Hotels X 200 rooms X 365 days X ….

Docker for Oracle5

Page 6: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Docker for Oracle6

Page 7: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Docker for Oracle7

Page 8: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Demand SupplyTechnology

Cache

Smart Cache Management

Docker for Oracle8

Page 9: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

MySQL MySQL MySQL MySQL

Shards

Bots

Docker for Oracle9

Page 10: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

MySQL MySQL MySQL MySQL

Shards

Bots

Data Pipe

based on Kafka

named Mississipi

has APIs and common libraries

Docker for Oracle10

Page 11: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Docker for Oracle11

Need:

Automatically spin up MySQL servers, with the right metadata!

Page 12: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Agenda

Docker for Oracle12

What’s the problem we are trying to solve?

How Docker solves the problem?

Installing and getting started with Docker

How is it different from Virtual Machines?

Docker in the Cloud—GCP, AWS, Oracle Cloud, etc.

Docker Compose, Swarm, etc..

Page 13: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Basic Command Structure• The word docker followed by a verb and optionally arguments

$ docker ps$ docker run mycontainer

• Help $ docker help$ docker ps help

Docker for Oracle13

Page 14: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Coloring Book• Example of building a Coloring Book• Docker Concepts– Image: a set of programs, or building blocks which can be deployed; but not deployed yet– Container: when you deploy an image. It’s the executable.

Docker for Oracle14

Page 15: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Pull Image• Pull images from docker hub

$ docker pull ubuntu• Pulls the image from the hub to the docker host• Show the images we have on the docker host

$ docker images

Docker for Oracle15

Page 16: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Bring up a container• Run a container

$ docker run ubuntu• See which containers are running

$ docker ps• See which containers were running earlier; but not now

$ docker ps -a• Containers do not stay up if they have nothing to do

Docker for Oracle16

Page 17: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Containers and Images

Docker for Oracle17

Image Container

on disk

Users

ModifiedContainer

Page 18: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Containers

Docker for Oracle18

Image Container

on disk

Copy 1

Copy 2

Page 19: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Running Apps in Containers• Verb run

$ docker run --name myhost ubuntu sleep 100• This will not let you come back • From a different terminal

$ docker ps• Stop the container• $ docker stop myhost• Remove the container

$ docker rm myhost

Docker for Oracle19

Page 20: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Detached mode• Run the container in detached mode to run in background

docker run -d --name myhost ubuntu sleep 100

Docker for Oracle20

Page 21: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Execute commands• Execute a command in a running container

$ docker exec -it myhost /bin/bash• This gives the OS prompt of the container• Options:– -i gives interactive prompt– -t gives TTY prompt (shell)

Docker for Oracle21

Page 22: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Execute in a container remotely• From Docker host

$ docker exec ContainerName Program• So to run docker exec myhost cat /etc/*release* in container myhost:

$ docker exec myhost cat /etc/*release* • A more practical example:• Shell script to compute bonus: /usr/bin/bonus.sh

$ docker exec myhost sh /usr/bin/bonus.sh 100

Docker for Oracle22

Page 23: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Persisting Changes• “Commit” Changes

$ docker commit Container Repository• Repository, not Image• You may add a “tag”

$ docker commit docker commit Container Repository:v1

Docker for Oracle23

Page 24: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Comparison with VMs

Docker for Oracle24

Host OS

VM VM

Linux Windows

App1 App2

Host OS

Container Container

App1 App2

Virtual Machine Docker

Page 25: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Volume• Databases need persistent data• Makes a filesystem persist in the host even after the container is shutdown• On the docker host, create a directory /dockervol• Add this to the container as a filesystem named /fs

$ docker run --name myhost -d -v /dockervol:/fs myubuntu1:v1 sleep 1000

• This will create a filesystem on the container named /fs

Docker for Oracle25

Page 26: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Copying files to/from containers• Copying

$ docker cp myhost:/var/www/html/index.html .

Docker for Oracle26

Page 27: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Port Mapping

Docker for Oracle27

myhost

Mycontainer1Port 80

Mycontainer2Port 80

http://myhost:80

Page 28: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Port Mapping

Docker for Oracle28

myhost

Mycontainer1Port 80

Mycontainer2Port 80

http://myhost:8080

8080

8081

Page 29: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Port Mapping• Start the container

$ docker run -d -p 8080:80 --name myhost ubuntu2 nginx -g "daemon off;"

• Now you can kick off the webpage– http://192.168.56.101:8080/– where 192.168.56.101 is the address of the Dockerhost.

Docker for Oracle29

Page 30: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Dockerfile• Create a file named Dockerfile in the directory /dockerfiles

FROM ubuntu:latestRUN apt-get updateRUN apt-get install -y vimRUN apt-get install -y nginxRUN echo "My first ubuntu docker image for vim and nginx" > /var/www/html/index.htmlEXPOSE 80

• Create the image from the dockerfile$ docker build -t ubuntu2 /dockerfiles

Docker for Oracle30

Page 31: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Changes in the file • To find out the changes in the files since the container was created,

$ docker diff myhost• Sample output:

$ docker diff myhostC /rootC /root/.bash_historyC /root/.viminfoC /tmpA /tmp/aC /usrC /usr/binC /usr/bin/bonus.sh

Docker for Oracle31

Page 32: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Inspect Containers• Get detailed inner settings of a container

$ docker inspect myhost2Shows all the important details

Docker for Oracle32

Page 33: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Get Usage• Stats

$ docker stats myhost2

Docker for Oracle33

Page 34: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Compose• Deploy multiple containers on multiple hosts• Uses a YAML file to define the various components

Docker for Oracle34

Page 35: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Swarm• Bring up multiple containers• A cluster• Automatically bring up containers • Automatically restart after failures

Docker for Oracle35

Page 36: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Container Clouds

Docker for Oracle36

MyImage

Container1

Container2

Amazon Container CloudOracle Container Cloud Service

Page 37: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Summary• Docker is just a set of processes running inside a host OS; it doesn’t have an OS• This makes it very quick to bring up and deploy• Takes very little memory and CPU• Also makes it less secure and isolated• Image: the executable programs and processes to be deployed• Container: the running processes• Docker Hub: the storage for all docker images• Dockerfile: a file that instructs what to do when building containers• Compose: a method to automate deployment of docker containers• Swarm: the automated way to manage a network of containers

Docker for Oracle37

Page 38: Jumpstarting Docker - proligence.com · Dockerfile • Create a file named Dockerfilein the directory /dockerfiles FROM ubuntu:latest RUN apt-get update RUN apt-get install -y vim

Thank You!

Blog: arup.blogspot.comTweeter: @ArupNandaFacebook.com/ArupKNanda

38Docker for Oracle