SlideShare a Scribd company logo
1 of 39
Getting started with
Docker
Geeta Vinnakota
Next 45 minutes
 What is docker and how can it help us?
 What is containerization and why does that matter?
 How is containerization different from virtualization?
How to install docker on Linux?
What is an image?
How do you build an image?
 What is a Dockerfile and why is it necessary?
How is a container different from an image?
 How does a docker deployment work flow with look like?
Command Reference
2/4/2016 1
Why Docker?
• Eliminate “But it works on my computer!” nightmares during deployments, by
exactly mirroring development and production environments
• Support quick replication of new production servers ~ within minutes
• Allows quick rollbacks ~ within minutes
• Advanced multi-container dockers play well with micro-service architecture by
enabling de-coupling and portability
( Keep an eye out and ask yourself, how these benefits are realized in the workflow, as you proceed with
the deck )
2/4/2016 2
What is Docker?
• What is Docker?
• Docker manages containers
• Docker allows shipping applications, code and services in containers
• What is a container?
• Containers can be compared to virtual machines, but much light-weight, faster with
less overhead
• Containers are isolated, independent, portable and easily reproducible
• Containerization vs Virtualization
• For an abstract view, containerization can be compared with virtualization
2/4/2016 3
Virtualization
2/4/2016 4
Image by Laura Frank, Sr Developer at Codeship
• Here is a host computer
with an installed hypervisor
• Hypervisor supports virtual
machines on a host
computer
• There are 3 virtual
machines installed on a
host in this diagram
• They share the resources of
the host computer
Containerization
2/4/2016 5
Image by Laura Frank, Sr Developer at Codeship
• Here is another host
computer
• Notice, that there is no
hypervisor or guest OS
Containerization
2/4/2016 6
Image by Laura Frank, Sr Developer at Codeship
• Instead of a hypervisor,
there is a container engine
• 3 containers are running
on the container engine
Docker ecosystem
provides us with a
container engine along
with a set of tools that
help us build and manage
containers
Installation
2/4/2016 7
Installating docker on Linux (ubuntu)
sudo apt-get update get latest package version
curl –sSL https://get.docker.com/ | sh install docker
docker -v check version
sudo usermod –aG docker ubuntu add default user ubuntu to docker group
docker info
docker history
• Linux – Package Installation described above
• Mac/Windows – Docker Toolbox. ( boot2docker is old and deprecated )
Images
2/4/2016 9
What is an image?
• An image is a template for a container
• It could be a simple command or complex software
• An image layer is a file system that is read-only
• A R-W file system is installed on top of the image layers
2/4/2016 10
How image builds work?
• After each RUN docker looks for a matching image in the build cache
• Build command compresses the context into an archive/tar and sends
it to the daemon
2/4/2016 11
How is an image different from a container?
Image
• Image is similar to a class in
programming
• Image ~ Blueprint
• Image is what you store on docker hub
& pass around
Container
• Container is similar an instance of the class
• Container ~ Actual Object
• You do not store containers anywhere or
pass them around
2/4/2016 12
• Consider the following differences and analogies to avoid confusion between images and
containers.
Types of Images
Service Image Project Base Image Official Image
• Offers a service out of the box
• You have to do very little to get
it functioning
• Nginx, Postgres, MySQL
• No service is offered out of the
box
• Ruby, Language based images
• Add your own code on top of
the image
• Maintained by the organization
or company itself
• An official image can serve as a
service or project based image
2/4/2016 13
Image Command Reference
Build an Image docker build –t repo_name/img_name:tag . build images from Dockerfile and
context
-t Tag the image with a repo name
Repo Name –
username/imagename
Rename docker tag local_repo:tag
docker_hub_repo:tag
Rename an image
docker tag img_id docker_hub_repo:tag Rename an image
List docker images List images
Remove docker rmi –f img_id/img_name Remove image
Inspect Details docker inspect img_id/img_name List port bindings, config
Login to Docker Hub docker login –username=uname –
password=pw –email=email
Pull Image from Hub docker pull username/image_name:tag
What is Dockerfile?
• A Dockerfile lets you create your own image
• It is a series of instructions to build your own image
• INSTRUCTIONS are typically upper case
• Best Practices
• Split long commands with backslashes
• Prefer COPY to ADD
• Minimize image layers by combining multiple RUN commands to avoid
multiple intermediate images, keeping readability in mind.
2/4/2016 15
Dockerfile Instruction Reference
Instruction Example Details
FROM FROM nginx Mandatory. First instruction.
Specifies base image
RUN RUN rm
/etc/nginx/defa
ult.conf
Execute the command while on the container
WORKDIR WORKDIR
/users/dan
Specify the working directory for the RUN commands
By default they are run in the root directory
CMD ping localhost Specify the default command of the image, that is run, when the
container is launched.
If there are multiple, the last one takes precedence
Process that runs with the container
Dockerfile Instruction Reference
EXPOSE EXPOSE 80 Expose ports on the container.
Does not map them to hosts
VOLUME VOLUME /var/log/nginx Creates a mount point with the specified name.
Marks it as holding volumes from native host
Does not map any volumes from the host
COPY COPY build/artifacts
/usr/share/nginx/html
Copies files from host to container
ADD Similar to COPY, but has additional capabilities of uncompressing
tar files, fetching files from remote locations
Prefer COPY to ADD unless specifically required
ENTRYPOINT Similar to CMD
Containers
2/4/2016 18
What is a container?
• Typically containers run a single process(default command).
Containers can be thought of, as the process they run.
• Container runs only as long as the default command is running
• Container itself is a process in the host machine. Any process run by
the container is a child process
• Containers have internal IP address
2/4/2016 19
How is a container different from a Virtual
Machine
• Container looks and operates like a Virtual Machine, but it is not a VM
• Containers are light weight. Spin up faster
• A host can accommodate more containers than VMs
• Containers run on top of docker engine
2/4/2016 20
Container Best Practices & Usecases
• Best Practices
• Specify names for containers to avoid strange auto generated names
• Containers are not suitable for persistent data, as they are ephemeral and
should allow stopping, destroying and recreating
• Do not run ssh servers in containers unless needed
• Use docker commands to check logs, restart processes, tweak configuration,
run upgrades
• Usecases
• Deploy web front-end applications
• Deploy web APIs
• Run Maintenance scripts
2/4/2016 21
Container Command Reference
Purpose Example Details
Run a container docker run –name docker-nginx –p
80:80 –d nginx
Creates a container with name
docker-nginx from image nginx
Flags for run -d Detached mode. Container runs in
the background and keeps running
until manually stopped
-p 80:80 Map local machine port 80 to
container port 80
Inspect docker inspect container_id | grep
IpAddress
List docker ps -a List containers including those that
are stopped
Troubleshooting a Container
Stop a container docker stop c_id Stop container with id c_id
Remove docker rm c_name Remove container with name
c_name
Enter a container docker exec –it c_id bash Takes you inside of a running
container to the bash
-it interactive ( also works with run
)
View logs from container docker logs c_id print logs of pid 1 process from the
container
docker logs –f c_id Follow logs from the container
docker logs –f –tail 10 c_id Follow logs from the last 10 lines
What is Docker Hub?
• Place to store and distribute docker images
• Think of it as github but for docker images
• Docker logo or prefix of library ‘library/nginx’ denotes official images
in the hub
• 70+ official, 100K+ regular, 300M+ downloads
2/4/2016 24
Traditional Deployment Workflow
2/4/2016 25
2/4/2016 26
• In a traditional
deployment flow, you
start with the host
machine
Traditional Deployment Workflow – Step 1 of 5
2/4/2016 27
• Install the
necessary tools
and services
• Start with
Installing Nginx
Nginx
Traditional Deployment Workflow – Step 2 of 5
2/4/2016 28
• Then more
software
provisioning
and
installations
• Ruby platform
Nginx
Ruby
Traditional Deployment Workflow – Step 3 of 5
2/4/2016 29
• Install the
necessary
dependencies
Nginx
Ruby
Dependencies
Traditional Deployment Workflow – Step 4 of 5
2/4/2016 30
• Finally deploy
the application
code and tie
everything
together into
an ecosystem
Nginx
Ruby
Dependencies
Application
Traditional Deployment Workflow – Step 5 of 5
Deployment Workflow with
Docker
2/4/2016 31
2/4/2016 32
• In Docker deployment
flow, we start with
installing docker enginer
on the host computer
• Cloud providers like
AWS provide machines
pre-provisioned with
docker, ready to use
Docker
Engine
Deployment Workflow with Docker – Step 1 of 2
2/4/2016 33
• Ship the entire
ecosystem, as a
container from your
development
environment ( as
opposed to
provisioning each
software separately )
Nginx
Ruby
Dependencies
Application
Docker
Engine
Deployment Workflow with Docker – Step 2 of 2
Production
Server
Docker
Image
Prd
Deploy
Package
Staging
Server
QA
Deploy
Package
Development
Machine
Image =
Application Code +
Software Needed to Run
the code
Deploy Package =
Location of Image on Hub
+ Access Credentials
• Image is nothing but a
versioned artifact
• Notice how all 3 versions
run the same image
• Which is what leads to no
surprise deploys ( exact
mirroring of development,
staging and production
servers
2/4/2016 35
Code Change
Create new docker image
docker build –t
repo/username:tag .
Push image to docker hub
docker push
repo/username:tag
Update image tag version
in dockerrun.aws.json
Web
or
CLI
Create a zip file (use gulp) with
dockerrun.aws.json &
.ebextensions. Upload it via
webconsole
CLI
’eb deploy’ Uploads a zip of
dockerrun.aws.json &
.ebextensions
Web CLI
Deploy Workflow
Docker using EB (Elastic
Beanstalk)
Tells Elastic Beanstalk
the location of the
docker image
Eliminate unrequired
files in image build by
adding .dockerignore
Tell EB to to pick only
dockerrun.aws.json
while create zip via
.ebignore
Advanced Features
2/4/2016 36
Volumes
• Volumes are mounted when creating a container
• Data in this volume is persistent even if the container is deleted
• Volumes are independent of the container lifecycle
• Volumes can be shared between containers
• Specify volumes in dockerfile using VOLUME instruction
• Best Practices:
• Mounting volumes from host for persistent data is not recommended as it
binds you to that host
• Cannot map volumes from host using dockerfile as it is intended to work on
any host
2/4/2016 37
Container Linking
• Container connection without using any network ports
• Step-1: Create the source container
• Step-2: Create the recipient container, with link to the source. It
creates an entry in the recipient with an alias and IP of the source
• Usecase: when you have separate web and database containers
• Source and recipient Containers can be on the same or different hosts
2/4/2016 38

More Related Content

What's hot

Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerUnder the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerDocker, Inc.
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for DummiesŁukasz Proszek
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and AgentRanjit Avasarala
 
Installation Openstack Swift
Installation Openstack SwiftInstallation Openstack Swift
Installation Openstack Swiftymtech
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 PresentationSreenivas Makam
 
CoreOS Overview and Current Status
CoreOS Overview and Current StatusCoreOS Overview and Current Status
CoreOS Overview and Current StatusSreenivas Makam
 
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...Docker, Inc.
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochranedotCloud
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
Continuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudContinuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudIdeato
 
Amazon EC2 Container Service in Action
Amazon EC2 Container Service in ActionAmazon EC2 Container Service in Action
Amazon EC2 Container Service in ActionRemotty
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker, Inc.
 
Deep Dive into Docker Swarm Mode
Deep Dive into Docker Swarm ModeDeep Dive into Docker Swarm Mode
Deep Dive into Docker Swarm ModeAjeet Singh Raina
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleRoman Rodomansky
 
Running Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeRunning Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeDanielle Madeley
 

What's hot (20)

Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, DockerUnder the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
 
Ansible not only for Dummies
Ansible not only for DummiesAnsible not only for Dummies
Ansible not only for Dummies
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
 
Docker
DockerDocker
Docker
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and Agent
 
Installation Openstack Swift
Installation Openstack SwiftInstallation Openstack Swift
Installation Openstack Swift
 
Docker 1.11 Presentation
Docker 1.11 PresentationDocker 1.11 Presentation
Docker 1.11 Presentation
 
What's New in Docker 1.12?
What's New in Docker 1.12?What's New in Docker 1.12?
What's New in Docker 1.12?
 
CoreOS Overview and Current Status
CoreOS Overview and Current StatusCoreOS Overview and Current Status
CoreOS Overview and Current Status
 
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken Cochrane
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Continuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in CloudContinuous Integration: SaaS vs Jenkins in Cloud
Continuous Integration: SaaS vs Jenkins in Cloud
 
Amazon EC2 Container Service in Action
Amazon EC2 Container Service in ActionAmazon EC2 Container Service in Action
Amazon EC2 Container Service in Action
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0
 
Deep Dive into Docker Swarm Mode
Deep Dive into Docker Swarm ModeDeep Dive into Docker Swarm Mode
Deep Dive into Docker Swarm Mode
 
Docker.io
Docker.ioDocker.io
Docker.io
 
Deploying Symfony2 app with Ansible
Deploying Symfony2 app with AnsibleDeploying Symfony2 app with Ansible
Deploying Symfony2 app with Ansible
 
Running Django on Docker: a workflow and code
Running Django on Docker: a workflow and codeRunning Django on Docker: a workflow and code
Running Django on Docker: a workflow and code
 

Viewers also liked

Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker, Inc.
 
Fake it till You Make it (Pick up New IT Skills Like a Maniac)
Fake it till You Make it  (Pick up New IT Skills Like a Maniac)Fake it till You Make it  (Pick up New IT Skills Like a Maniac)
Fake it till You Make it (Pick up New IT Skills Like a Maniac)Hank Huang
 
A lógica da reencarnação
A lógica da reencarnaçãoA lógica da reencarnação
A lógica da reencarnaçãoMarcos Arouca
 
VM Farms Thrive with Dedicated IP Storage Networks
VM Farms Thrive with Dedicated IP Storage NetworksVM Farms Thrive with Dedicated IP Storage Networks
VM Farms Thrive with Dedicated IP Storage NetworksBrocade
 
Liliana rivas gonzalez_actividad1_mapa_c
Liliana rivas gonzalez_actividad1_mapa_cLiliana rivas gonzalez_actividad1_mapa_c
Liliana rivas gonzalez_actividad1_mapa_clilianarigo
 
Docker 101 2015-05-28
Docker 101 2015-05-28Docker 101 2015-05-28
Docker 101 2015-05-28Adrian Otto
 
Nginx internals
Nginx internalsNginx internals
Nginx internalsliqiang xu
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...addame
 
Lcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINXLcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINXLinaro
 
Docker use dockerfile
Docker use dockerfileDocker use dockerfile
Docker use dockerfilecawamata
 
Introduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM'sIntroduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM'sJeremy Haas
 
Docker Internals - Twilio talk November 14th, 2013
Docker Internals - Twilio talk November 14th, 2013Docker Internals - Twilio talk November 14th, 2013
Docker Internals - Twilio talk November 14th, 2013Guillaume Charmes
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90minsLarry Cai
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINXWallarm
 

Viewers also liked (20)

Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
 
Fake it till You Make it (Pick up New IT Skills Like a Maniac)
Fake it till You Make it  (Pick up New IT Skills Like a Maniac)Fake it till You Make it  (Pick up New IT Skills Like a Maniac)
Fake it till You Make it (Pick up New IT Skills Like a Maniac)
 
Srv p18-intro-v30
Srv p18-intro-v30Srv p18-intro-v30
Srv p18-intro-v30
 
A lógica da reencarnação
A lógica da reencarnaçãoA lógica da reencarnação
A lógica da reencarnação
 
VM Farms Thrive with Dedicated IP Storage Networks
VM Farms Thrive with Dedicated IP Storage NetworksVM Farms Thrive with Dedicated IP Storage Networks
VM Farms Thrive with Dedicated IP Storage Networks
 
Liliana rivas gonzalez_actividad1_mapa_c
Liliana rivas gonzalez_actividad1_mapa_cLiliana rivas gonzalez_actividad1_mapa_c
Liliana rivas gonzalez_actividad1_mapa_c
 
Docker 101 2015-05-28
Docker 101 2015-05-28Docker 101 2015-05-28
Docker 101 2015-05-28
 
Nginx internals
Nginx internalsNginx internals
Nginx internals
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
 
Nginx
NginxNginx
Nginx
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
Lcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINXLcu14 Lightning Talk- NGINX
Lcu14 Lightning Talk- NGINX
 
Docker use dockerfile
Docker use dockerfileDocker use dockerfile
Docker use dockerfile
 
Introduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM'sIntroduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM's
 
Docker Internals - Twilio talk November 14th, 2013
Docker Internals - Twilio talk November 14th, 2013Docker Internals - Twilio talk November 14th, 2013
Docker Internals - Twilio talk November 14th, 2013
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
Docker
DockerDocker
Docker
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINX
 
Docker volume
Docker volumeDocker volume
Docker volume
 

Similar to Getting Started with Docker

Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentalsAlper Unal
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsElasTest Project
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with DockerRavindu Fernando
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerKuan Yen Heng
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesabhishek chawla
 
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...IBM France Lab
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptxVipobav
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and MicroserviceSamuel Chow
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101Naukri.com
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with dockerMichelle Liu
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataInfluxData
 
Rails Applications with Docker
Rails Applications with DockerRails Applications with Docker
Rails Applications with DockerLaura Frank Tacho
 
Docker on Power Systems
Docker on Power SystemsDocker on Power Systems
Docker on Power SystemsCesar Maciel
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsRamit Surana
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for DevelopmentChris Tankersley
 

Similar to Getting Started with Docker (20)

Docker
DockerDocker
Docker
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
 
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and JenkinsExpoQA 2017 Using docker to build and test in your laptop and Jenkins
ExpoQA 2017 Using docker to build and test in your laptop and Jenkins
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Virtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management servicesVirtualization, Containers, Docker and scalable container management services
Virtualization, Containers, Docker and scalable container management services
 
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
Rails Applications with Docker
Rails Applications with DockerRails Applications with Docker
Rails Applications with Docker
 
Docker on Power Systems
Docker on Power SystemsDocker on Power Systems
Docker on Power Systems
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and tools
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 

Recently uploaded

Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 

Recently uploaded (20)

Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 

Getting Started with Docker

  • 2. Next 45 minutes  What is docker and how can it help us?  What is containerization and why does that matter?  How is containerization different from virtualization? How to install docker on Linux? What is an image? How do you build an image?  What is a Dockerfile and why is it necessary? How is a container different from an image?  How does a docker deployment work flow with look like? Command Reference 2/4/2016 1
  • 3. Why Docker? • Eliminate “But it works on my computer!” nightmares during deployments, by exactly mirroring development and production environments • Support quick replication of new production servers ~ within minutes • Allows quick rollbacks ~ within minutes • Advanced multi-container dockers play well with micro-service architecture by enabling de-coupling and portability ( Keep an eye out and ask yourself, how these benefits are realized in the workflow, as you proceed with the deck ) 2/4/2016 2
  • 4. What is Docker? • What is Docker? • Docker manages containers • Docker allows shipping applications, code and services in containers • What is a container? • Containers can be compared to virtual machines, but much light-weight, faster with less overhead • Containers are isolated, independent, portable and easily reproducible • Containerization vs Virtualization • For an abstract view, containerization can be compared with virtualization 2/4/2016 3
  • 5. Virtualization 2/4/2016 4 Image by Laura Frank, Sr Developer at Codeship • Here is a host computer with an installed hypervisor • Hypervisor supports virtual machines on a host computer • There are 3 virtual machines installed on a host in this diagram • They share the resources of the host computer
  • 6. Containerization 2/4/2016 5 Image by Laura Frank, Sr Developer at Codeship • Here is another host computer • Notice, that there is no hypervisor or guest OS
  • 7. Containerization 2/4/2016 6 Image by Laura Frank, Sr Developer at Codeship • Instead of a hypervisor, there is a container engine • 3 containers are running on the container engine Docker ecosystem provides us with a container engine along with a set of tools that help us build and manage containers
  • 9. Installating docker on Linux (ubuntu) sudo apt-get update get latest package version curl –sSL https://get.docker.com/ | sh install docker docker -v check version sudo usermod –aG docker ubuntu add default user ubuntu to docker group docker info docker history • Linux – Package Installation described above • Mac/Windows – Docker Toolbox. ( boot2docker is old and deprecated )
  • 11. What is an image? • An image is a template for a container • It could be a simple command or complex software • An image layer is a file system that is read-only • A R-W file system is installed on top of the image layers 2/4/2016 10
  • 12. How image builds work? • After each RUN docker looks for a matching image in the build cache • Build command compresses the context into an archive/tar and sends it to the daemon 2/4/2016 11
  • 13. How is an image different from a container? Image • Image is similar to a class in programming • Image ~ Blueprint • Image is what you store on docker hub & pass around Container • Container is similar an instance of the class • Container ~ Actual Object • You do not store containers anywhere or pass them around 2/4/2016 12 • Consider the following differences and analogies to avoid confusion between images and containers.
  • 14. Types of Images Service Image Project Base Image Official Image • Offers a service out of the box • You have to do very little to get it functioning • Nginx, Postgres, MySQL • No service is offered out of the box • Ruby, Language based images • Add your own code on top of the image • Maintained by the organization or company itself • An official image can serve as a service or project based image 2/4/2016 13
  • 15. Image Command Reference Build an Image docker build –t repo_name/img_name:tag . build images from Dockerfile and context -t Tag the image with a repo name Repo Name – username/imagename Rename docker tag local_repo:tag docker_hub_repo:tag Rename an image docker tag img_id docker_hub_repo:tag Rename an image List docker images List images Remove docker rmi –f img_id/img_name Remove image Inspect Details docker inspect img_id/img_name List port bindings, config Login to Docker Hub docker login –username=uname – password=pw –email=email Pull Image from Hub docker pull username/image_name:tag
  • 16. What is Dockerfile? • A Dockerfile lets you create your own image • It is a series of instructions to build your own image • INSTRUCTIONS are typically upper case • Best Practices • Split long commands with backslashes • Prefer COPY to ADD • Minimize image layers by combining multiple RUN commands to avoid multiple intermediate images, keeping readability in mind. 2/4/2016 15
  • 17. Dockerfile Instruction Reference Instruction Example Details FROM FROM nginx Mandatory. First instruction. Specifies base image RUN RUN rm /etc/nginx/defa ult.conf Execute the command while on the container WORKDIR WORKDIR /users/dan Specify the working directory for the RUN commands By default they are run in the root directory CMD ping localhost Specify the default command of the image, that is run, when the container is launched. If there are multiple, the last one takes precedence Process that runs with the container
  • 18. Dockerfile Instruction Reference EXPOSE EXPOSE 80 Expose ports on the container. Does not map them to hosts VOLUME VOLUME /var/log/nginx Creates a mount point with the specified name. Marks it as holding volumes from native host Does not map any volumes from the host COPY COPY build/artifacts /usr/share/nginx/html Copies files from host to container ADD Similar to COPY, but has additional capabilities of uncompressing tar files, fetching files from remote locations Prefer COPY to ADD unless specifically required ENTRYPOINT Similar to CMD
  • 20. What is a container? • Typically containers run a single process(default command). Containers can be thought of, as the process they run. • Container runs only as long as the default command is running • Container itself is a process in the host machine. Any process run by the container is a child process • Containers have internal IP address 2/4/2016 19
  • 21. How is a container different from a Virtual Machine • Container looks and operates like a Virtual Machine, but it is not a VM • Containers are light weight. Spin up faster • A host can accommodate more containers than VMs • Containers run on top of docker engine 2/4/2016 20
  • 22. Container Best Practices & Usecases • Best Practices • Specify names for containers to avoid strange auto generated names • Containers are not suitable for persistent data, as they are ephemeral and should allow stopping, destroying and recreating • Do not run ssh servers in containers unless needed • Use docker commands to check logs, restart processes, tweak configuration, run upgrades • Usecases • Deploy web front-end applications • Deploy web APIs • Run Maintenance scripts 2/4/2016 21
  • 23. Container Command Reference Purpose Example Details Run a container docker run –name docker-nginx –p 80:80 –d nginx Creates a container with name docker-nginx from image nginx Flags for run -d Detached mode. Container runs in the background and keeps running until manually stopped -p 80:80 Map local machine port 80 to container port 80 Inspect docker inspect container_id | grep IpAddress List docker ps -a List containers including those that are stopped
  • 24. Troubleshooting a Container Stop a container docker stop c_id Stop container with id c_id Remove docker rm c_name Remove container with name c_name Enter a container docker exec –it c_id bash Takes you inside of a running container to the bash -it interactive ( also works with run ) View logs from container docker logs c_id print logs of pid 1 process from the container docker logs –f c_id Follow logs from the container docker logs –f –tail 10 c_id Follow logs from the last 10 lines
  • 25. What is Docker Hub? • Place to store and distribute docker images • Think of it as github but for docker images • Docker logo or prefix of library ‘library/nginx’ denotes official images in the hub • 70+ official, 100K+ regular, 300M+ downloads 2/4/2016 24
  • 27. 2/4/2016 26 • In a traditional deployment flow, you start with the host machine Traditional Deployment Workflow – Step 1 of 5
  • 28. 2/4/2016 27 • Install the necessary tools and services • Start with Installing Nginx Nginx Traditional Deployment Workflow – Step 2 of 5
  • 29. 2/4/2016 28 • Then more software provisioning and installations • Ruby platform Nginx Ruby Traditional Deployment Workflow – Step 3 of 5
  • 30. 2/4/2016 29 • Install the necessary dependencies Nginx Ruby Dependencies Traditional Deployment Workflow – Step 4 of 5
  • 31. 2/4/2016 30 • Finally deploy the application code and tie everything together into an ecosystem Nginx Ruby Dependencies Application Traditional Deployment Workflow – Step 5 of 5
  • 33. 2/4/2016 32 • In Docker deployment flow, we start with installing docker enginer on the host computer • Cloud providers like AWS provide machines pre-provisioned with docker, ready to use Docker Engine Deployment Workflow with Docker – Step 1 of 2
  • 34. 2/4/2016 33 • Ship the entire ecosystem, as a container from your development environment ( as opposed to provisioning each software separately ) Nginx Ruby Dependencies Application Docker Engine Deployment Workflow with Docker – Step 2 of 2
  • 35. Production Server Docker Image Prd Deploy Package Staging Server QA Deploy Package Development Machine Image = Application Code + Software Needed to Run the code Deploy Package = Location of Image on Hub + Access Credentials • Image is nothing but a versioned artifact • Notice how all 3 versions run the same image • Which is what leads to no surprise deploys ( exact mirroring of development, staging and production servers
  • 36. 2/4/2016 35 Code Change Create new docker image docker build –t repo/username:tag . Push image to docker hub docker push repo/username:tag Update image tag version in dockerrun.aws.json Web or CLI Create a zip file (use gulp) with dockerrun.aws.json & .ebextensions. Upload it via webconsole CLI ’eb deploy’ Uploads a zip of dockerrun.aws.json & .ebextensions Web CLI Deploy Workflow Docker using EB (Elastic Beanstalk) Tells Elastic Beanstalk the location of the docker image Eliminate unrequired files in image build by adding .dockerignore Tell EB to to pick only dockerrun.aws.json while create zip via .ebignore
  • 38. Volumes • Volumes are mounted when creating a container • Data in this volume is persistent even if the container is deleted • Volumes are independent of the container lifecycle • Volumes can be shared between containers • Specify volumes in dockerfile using VOLUME instruction • Best Practices: • Mounting volumes from host for persistent data is not recommended as it binds you to that host • Cannot map volumes from host using dockerfile as it is intended to work on any host 2/4/2016 37
  • 39. Container Linking • Container connection without using any network ports • Step-1: Create the source container • Step-2: Create the recipient container, with link to the source. It creates an entry in the recipient with an alias and IP of the source • Usecase: when you have separate web and database containers • Source and recipient Containers can be on the same or different hosts 2/4/2016 38