Jumpstarting Docker
Arup Nanda
VP, Data Services
Priceline.com
My application worked in Dev but not in QA
Will it work in production?
I need an environment right now
No, 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?.
Docker for Oracle
2
booking.com|priceline.com|kayak.com|agoda.com|rentalcars.com|opentable.com
Docker for Oracle
3
Bots
Demand Technology Supply
Docker for Oracle
4
WWW Providers
Affiliates GDS
White
labels Affiliates
Inventory
250K Hotels X 200 rooms X 365 days X ….
Demand Technology Supply
Docker for Oracle
5
Docker for Oracle
6
Docker for Oracle
7
Cache
Demand Technology Supply
Smart Cache Management
Docker for Oracle
8
Bots
MySQL MySQL MySQL MySQL
Shards
Docker for Oracle
9
based on Kafka
Bots
named Mississipi
has APIs and
Data Pipe common libraries
MySQL MySQL MySQL MySQL
Shards
Docker for Oracle
10
Need:
Automatically spin up
MySQL servers, with
the right metadata!
Docker for Oracle
11
Agenda
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..
Docker for Oracle
12
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 Oracle
13
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 Oracle
14
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 Oracle
15
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 Oracle
16
Containers and Images
Users
Modified
Image Container
Container
on disk
Docker for Oracle
17
Containers
Copy 1
Image Container
Copy 2
on disk
Docker for Oracle
18
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 Oracle
19
Detached mode
• Run the container in detached mode to run in background
docker run -d --name myhost ubuntu sleep 100
Docker for Oracle
20
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 Oracle
21
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 Oracle
22
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 Oracle
23
Comparison with VMs
Virtual Machine Docker
App1 App2 App1 App2
Container Container
Linux Windows
VM VM
Host OS Host OS
Docker for Oracle
24
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 Oracle
25
Copying files to/from containers
• Copying
$ docker cp myhost:/var/www/html/index.html .
Docker for Oracle
26
Port Mapping
Mycontainer1
Port 80
myhost http://myhost:80
Mycontainer2
Port 80
Docker for Oracle
27
Port Mapping
Mycontainer1
Port 80
8080
myhost
8081
Mycontainer2
Port 80
http://myhost:8080
Docker for Oracle
28
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 Oracle
29
Dockerfile
• Create a file named Dockerfile in the directory /dockerfiles
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y vim
RUN apt-get install -y nginx
RUN echo "My first ubuntu docker image for vim and nginx" >
/var/www/html/index.html
EXPOSE 80
• Create the image from the dockerfile
$ docker build -t ubuntu2 /dockerfiles
Docker for Oracle
30
Changes in the file
• To find out the changes in the files since the container was created,
$ docker diff myhost
• Sample output:
$ docker diff myhost
C /root
C /root/.bash_history
C /root/.viminfo
C /tmp
A /tmp/a
C /usr
C /usr/bin
C /usr/bin/bonus.sh
Docker for Oracle
31
Inspect Containers
• Get detailed inner settings of a container
$ docker inspect myhost2
Shows all the important details
Docker for Oracle
32
Get Usage
• Stats
$ docker stats myhost2
Docker for Oracle
33
Compose
• Deploy multiple containers on multiple hosts
• Uses a YAML file to define the various components
Docker for Oracle
34
Swarm
• Bring up multiple containers
• A cluster
• Automatically bring up containers
• Automatically restart after failures
Docker for Oracle
35
Container Clouds
Container2
Amazon Container Cloud
MyImage
Oracle Container Cloud Service
Container1
Docker for Oracle
36
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 Oracle
37
Thank You!
Blog: arup.blogspot.com
Tweeter: @ArupNanda
Facebook.com/ArupKNanda
Docker for Oracle 38