SlideShare a Scribd company logo
Up and Running
With Docker
Presented by Michelle Liu
https://github.com/anonmily/docker-up-and-running
Outline
1. What is Docker?
2. Applications of Docker
3. Terminology: How Docker Works
4. Tools
5. Installation
6. Images
7. Containers
8. Docker Registry
9. Docker Workflow
10. Docker Remote API
11. QA
The Deployment Dilemma
• Inter-dependent dependencies
• Inconsistent environments
• Development != Production
• “Works on my machine…”
The Deployment Dilemma
Lots of dependencies/interactions between services and applications
Different approaches and tools
• Virtualization
• Configuration Management
• Containers
Containerization = standardization
Containerization = Separation of Concerns
Configuration Management
Remember the exact steps needed for
setup and do it all over again for all of
your servers (a recipe)
Docker/Containers
Set up a container/image just once with all
the necessary configuration, then deploy the
same image to all of your servers (a golden
image)
What’s the difference?
Terminology: Images and Containers
Image: A master template for creating Docker
containers, analogous to virtual machine
instances (a “golden image”)
Container: An instance of an image; multiple
containers can be created from a single image.
A container contains isolated processes and
filesystems acting in a similar fashion as virtual
machines; however, a container only includes
the filesystem on top of a shared kernel.
Virtual Machines Containers
What’s the difference? Virtual Machines vs Containers
Virtual Machines
• Kernel not shared between virtual
machines
• Isolated operating systems
• Long-lasting use
• Slower to get running
• Many startup processes
• A single virtual machine image can be
used for multiple virtual machine
clones
Containers
• Kernel of linux host shared between all
containers
• Isolated processes/filesystems
• Ephemeral/long-lasting usage
• Fast to get running
• One startup process
• A single Docker image can be used for
multiple container instances
What’s the difference? Virtual Machines vs Containers
What is Docker used for?
• Ephemeral (temporary) isolated processes (e.g. Codepen, Codeship)
• Short running tasks, maintenance scripts, or worker processes that
receive then process a workload
• Running and deploying stateless applications
• Web frontends and backend APIs
• Running isolated environments with imposed CPU/memory limits
• …and more!
This means that containers are
• More lightweight
• Can be started, stopped, and
restarted more quickly
• Easier to migrate
• Easier to communicate
between containers
What’s the difference? Virtual Machines vs Containers
Docker Server vs Docker Client
Docker server/daemon:
The docker server/daemon runs containers within as
processes, acting as a virtual bridge to the host operating
system (containers are isolated)
Docker client: The command line interface (CLI) that is
able to connect to the Docker server (specified by the
DOCKER_HOST environmental variable) and tell it what to
do. This can run on your local machine or on the same
host as the Docker server.
Docker Server vs CLI
Docker Server vs CLI
Docker Server vs CLI
Docker Server vs CLI
Docker Server vs CLI
WORKSHOP
Install Docker
Installation - Linux
curl -fsSL https://get.docker.com/ | sh
service docker start
Will run a setup script for installing docker
Easy setup
Installation - Linux
apt-get update
apt-get purge lxc-docker*
apt-get purge docker.io*
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys
58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo debian-jessie main" >
/etc/apt/sources.list.d/docker.list
apt-get -y install apt-transport-https
apt-get -y update
apt-get -y install docker-engine
service docker start
Debian/Ubuntu
curl https://raw.githubusercontent.com/anonmily/scripts/master/docker-setup-debian | bash
Or, just
Installation - Linux
yum install docker
service docker start
Fedora
curl https://raw.githubusercontent.com/anonmily/scripts/master/docker-setup-yum | bash
Or, just
Installation – Non-Linux
• Download and install the Docker
Toolbox
https://www.docker.com/docker-
toolbox
• Open the Docker Quickstart
Terminal
WORKSHOP
Docker Server/CLI
Docker Server/CLI
docker-machine create –driver virtualbox host1
docker-machine create –driver virtualbox host2
docker-machine create –driver virtualbox host3
Create a new docker host
docker-machine ls
List docker hosts
Docker Server/CLI
docker-machine stop host1
Stop docker host
docker-machine start host1
Start docker host
docker-machine restart host1
Restart docker host
Docker Server/CLI
docker-machine ip host1
Get IP address of host
docker-machine env host1
Get environmental variables of the host
Docker Server/CLI
eval $(docker-machine-env host1)
Set environmental variables of CLI to communicate with a host
** If you get a “Cannot connect to the Docker daemon. Is the docker daemon running on this host?” error
when attempting to use the Docker CLI, make sure the environmental variables are set for your Docker host
Docker Images
• Docker images are a saved state of the
container. They’re the “golden image” for
your containers, and multiple containers
based off the same mage can be run at
the same time (executing different
commands etc in the same environment if
necessary)
• Image ID = hashed representation of the
image, a unique identifier
• A Dockerfile is a file that describes all the
steps needed to build a Docker image
Docker Images
• Images can be tagged with a name
and a version label (e.g.
nginx:latest, ubuntu:14:04)
• Images are stored in and can be
retrieve from Docker Repositories
• Docker Hub: Public repository with
common base images
• Private Registry: Deploy your own
Docker registry
Storing Docker Images
• Docker registry: A server that hosts your
Docker images; it acts in a fashion
analogous to repositories in that you can
push and pull images from the registry.
You can use a public registry like Docker
hub, or you can setup your own for private
images.
• Docker Hub: A public Docker registry that
is the default for pulling images. It
provides many common base images such
as Debian, Ubuntu, Fedora, etc.
Docker Hub
Deploy your own registry server
WORKSHOP
Docker Images
Docker Images
docker pull nginx:latest
Pull/get an image (from Docker Hub)
# login to DockerHub
docker login
# private registry
docker login https://myownregistry.com:5000
Login to a registry
• Docker will save your login credentials in ~/.docker/config.json
docker images
See your downloaded/available images
Docker Images
docker build –t webapp1:latest .
Build a new image tagged “webapp1:latest” from a Dockerfile
docker run --name="myapp" -p 80:80 -d nginx:latest nginx
-g "daemon off;"
Run a container from an image
• --name=“myapp” Run a new container called “myapp”
• -p 80:80 Expose port 80 of the host and map it to port 80 of the container
• -d Run daemonized
• nginx:latest Base image
• nginx –g “daemon off;” Command to start the container with
Docker Images
docker exec –it nodeapp bash
Execute a command into a container
docker ps # running containers
docker ps –a # all containers
List containers
docker stop nodeapp
Stop container
docker rm nodeapp
Remove container
Docker Images
docker save myimage:latest > myimage.tar
Save an image to a tarball
docker import myimage.tar
Import an image from a tarball
docker commit –m “newconfig” mycontainer myimage:latest
Commit/save the current state of a container to the image
Docker Images
docker rmi myimage:latest
Remove an image
docker rmi $(docker images –q –f “dangling=true”)
Delete all untagged images
docker rmi $(docker images –q -)
Delete all images on Docker host
What is a Dockerfile?
• Instructions for how to build a
Docker image
FROM anonmily/node:latest
MAINTAINER Michelle Liu
<michelle@michelleliu.io>
COPY src/node_modules /src/node_modules
COPY certs /src/certs
EXPOSE 443
WORKDIR /src
ENV PATH /src/bin:$PATH
COPY src/bin /src/bin
COPY src/app /src/app
COPY src/server.js src/app.js
src/package.json Makefile /src/
CMD ["startserver"]
Anatomy of a Dockerfile
• FROM what base image to use for the new image
• MAINTAINER who maintains the image
• COPY source destination copy files from the source location to destination
• ENV set environmental variables
• WORKDIR set working directory of the container
• CMD run command
• EXPOSE indicates what ports should be available for exposure
Dockerizing a Node application
FROM anonmily/node:latest
MAINTAINER Michelle Liu
<michelle@michelleliu.io>
COPY src/node_modules /src/node_modules
COPY certs /src/certs
EXPOSE 443
WORKDIR /src
ENV PATH /src/bin:$PATH
COPY src/bin /src/bin
COPY src/app /src/app
COPY src/server.js src/app.js
src/package.json Makefile /src/
CMD ["startserver"]
/Src
app/
app.js
bin/
startserver
certs
gulpfile.js
node_modules
server.js
Makefile
Bin/
Certs/
Src/
app.js
bin/
startserver
gulpfile.js
node_modules
server.js
Server.js
Production.env
Dockerfile
Makefile
Original Folder Docker Container
Utilizing the Layer Cache
FROM anonmily/node:latest
MAINTAINER Michelle Liu <michelle@michelleliu.io>
COPY src/node_modules /src/node_modules
COPY certs /src/certs
EXPOSE 443
WORKDIR /src
ENV PATH /src/bin:$PATH
COPY src/bin /src/bin
COPY src/app /src/app
COPY src/server.js src/app.js src/package.json
Makefile /src/
CMD ["startserver"]
Least changed
files on top
More
frequently
changed files
on bottom
Building the image
# ./bin/buildapi
docker build -t myregistry.com/nodeapi:latest .
# ./bin/pushapi
docker push myregistry.com/nodeapi:latest
Updating to a newer image
# ./bin/updatecontainer
docker pull myregistry.com/nodeapi:latest
docker kill nodeapicontainer;
docker rm nodeapicontainer;
docker run --name nodeapi01 
-p 443:443 
-dit 
--env-file /home/production.env 
myregistry.com/nodeapi:latest 
startserver
An easy way to deploy
1. Push the new image up onto the Docker registry (e.g. 1.0.0)
2. From the servers, pull down the new image
3. Kill the currently running container based off the old outdated image
4. Run a new container based off the new image
Updating to a newer image
#!/bin/bash
docker build -t myregistry.com/nodeapi:latest .
docker push myregistry.com/nodeapi:latest
ssh -i ~/.ssh/mysshkey root@api.mysite.com 'bash' <
bin/updatecontainer
ssh -i ~/.ssh/mysshkey root@api.mysite2.com 'bash' <
bin/updatecontainer
ssh -i ~/.ssh/mysshkey root@api.mysite3.com 'bash' <
bin/updatecontainer
Startserver
#!/bin/bash
pm2 dump
pm2 start /src/server.js -i 0 --name
nodeapi --no-daemon &
If you want to start your container up with more than
one command, use a bash script
Docker remote API
An API for the Docker daemon/server that allows you to make requests
to/query the server for creating/editing or for information on
containers/images.
Docker remote API
By default, the Docker daemon will run on the unix port at
/var/run/docker.sock. To get started with the Docker remote API, make sure
that you have a cURL version greater than 7.40 so that the –unix-socket
option is available. Then, we can use curl to interact with the remote API by:
curl --unix-socket /var/run/docker.sock http://containers/json
Docker remote API
It’s also possible to bind the Docker daemon to a TCP port at startup by:
docker daemon –H tcp://0.0.0.0:2375 –H /var/run/docker.sock
It will then be possible to access the remote API on the host publicly (though
it is a security issue).
curl http://localhost:2375/containers/json
More resources
• http://view.dckr.info/DockerIntro.pdf
• http://view.dckr.info/DockerAdvanced.pdf
• https://docs.docker.com/engine/articles/dockerfile_best-practices/
• http://blog.thoward37.me/articles/where-are-docker-images-stored/
• http://blog.trifork.com/2013/12/24/docker-from-a-distance-the-remote-api/
Ad

More Related Content

What's hot (20)

Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
CodeOps Technologies LLP
 
Docker
DockerDocker
Docker
Chen Chun
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Jeffrey Ellin
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
Dr. Syed Hassan Amin
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Edureka!
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
Balaji Rajan
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
DuckDuckGo
 
Docker : Container Virtualization
Docker : Container VirtualizationDocker : Container Virtualization
Docker : Container Virtualization
Ranjan Baisak
 
Docker Basic Presentation
Docker Basic PresentationDocker Basic Presentation
Docker Basic Presentation
Aman Chhabra
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
andrzejsydor
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
Araf Karsh Hamid
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
Saeed Hajizade
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebration
Ramon Morales
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
Walid Ashraf
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Simplilearn
 
Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
Alper Unal
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
Ben Hall
 
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
dotCloud
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
psconnolly
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Edureka!
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
Balaji Rajan
 
Docker : Container Virtualization
Docker : Container VirtualizationDocker : Container Virtualization
Docker : Container Virtualization
Ranjan Baisak
 
Docker Basic Presentation
Docker Basic PresentationDocker Basic Presentation
Docker Basic Presentation
Aman Chhabra
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
andrzejsydor
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebration
Ramon Morales
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
Walid Ashraf
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Simplilearn
 
Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
Alper Unal
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
Ben Hall
 
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
Docker Presentation at the OpenStack Austin Meetup | 2013-09-12
dotCloud
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
psconnolly
 

Similar to Up and running with docker (20)

Getting Started With Docker: Simplifying DevOps
Getting Started With Docker: Simplifying DevOpsGetting Started With Docker: Simplifying DevOps
Getting Started With Docker: Simplifying DevOps
demoNguyen
 
Docker Introduction and its Usage in Machine Learning
Docker Introduction and its Usage in Machine LearningDocker Introduction and its Usage in Machine Learning
Docker Introduction and its Usage in Machine Learning
yogendra18
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
Vipobav
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
Naukri.com
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
Araf Karsh Hamid
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
Giacomo Vacca
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
Samuel Chow
 
How to _docker
How to _dockerHow to _docker
How to _docker
Abdur Rab Marjan
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
JasonStraughan1
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
Shankar Chaudhary
 
Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)
Eric Smalling
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
fazalraja
 
Docker 1.9 Workshop
Docker 1.9 WorkshopDocker 1.9 Workshop
Docker 1.9 Workshop
{code}
 
Docker slides
Docker slidesDocker slides
Docker slides
Jyotsna Raghuraman
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Swaminathan Vetri
 
Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker @ Atlogys
Atlogys Technical Consulting
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
Docker-Hanoi
 
14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt
aravym456
 
Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021
Alessandro Mignogna
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
Yonghwee Kim
 
Getting Started With Docker: Simplifying DevOps
Getting Started With Docker: Simplifying DevOpsGetting Started With Docker: Simplifying DevOps
Getting Started With Docker: Simplifying DevOps
demoNguyen
 
Docker Introduction and its Usage in Machine Learning
Docker Introduction and its Usage in Machine LearningDocker Introduction and its Usage in Machine Learning
Docker Introduction and its Usage in Machine Learning
yogendra18
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
Vipobav
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
Naukri.com
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
Samuel Chow
 
Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)
Eric Smalling
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
fazalraja
 
Docker 1.9 Workshop
Docker 1.9 WorkshopDocker 1.9 Workshop
Docker 1.9 Workshop
{code}
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Swaminathan Vetri
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
Docker-Hanoi
 
14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt14309525_docker_docker_docker_docker_introduction.ppt
14309525_docker_docker_docker_docker_introduction.ppt
aravym456
 
Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021Primi passi con Docker - ItalianCoders - 12-01-2021
Primi passi con Docker - ItalianCoders - 12-01-2021
Alessandro Mignogna
 
Ad

Recently uploaded (20)

Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Ad

Up and running with docker

  • 1. Up and Running With Docker Presented by Michelle Liu https://github.com/anonmily/docker-up-and-running
  • 2. Outline 1. What is Docker? 2. Applications of Docker 3. Terminology: How Docker Works 4. Tools 5. Installation 6. Images 7. Containers 8. Docker Registry 9. Docker Workflow 10. Docker Remote API 11. QA
  • 3. The Deployment Dilemma • Inter-dependent dependencies • Inconsistent environments • Development != Production • “Works on my machine…”
  • 5. Lots of dependencies/interactions between services and applications
  • 6. Different approaches and tools • Virtualization • Configuration Management • Containers
  • 9. Configuration Management Remember the exact steps needed for setup and do it all over again for all of your servers (a recipe) Docker/Containers Set up a container/image just once with all the necessary configuration, then deploy the same image to all of your servers (a golden image) What’s the difference?
  • 10. Terminology: Images and Containers Image: A master template for creating Docker containers, analogous to virtual machine instances (a “golden image”) Container: An instance of an image; multiple containers can be created from a single image. A container contains isolated processes and filesystems acting in a similar fashion as virtual machines; however, a container only includes the filesystem on top of a shared kernel.
  • 11. Virtual Machines Containers What’s the difference? Virtual Machines vs Containers
  • 12. Virtual Machines • Kernel not shared between virtual machines • Isolated operating systems • Long-lasting use • Slower to get running • Many startup processes • A single virtual machine image can be used for multiple virtual machine clones Containers • Kernel of linux host shared between all containers • Isolated processes/filesystems • Ephemeral/long-lasting usage • Fast to get running • One startup process • A single Docker image can be used for multiple container instances What’s the difference? Virtual Machines vs Containers
  • 13. What is Docker used for? • Ephemeral (temporary) isolated processes (e.g. Codepen, Codeship) • Short running tasks, maintenance scripts, or worker processes that receive then process a workload • Running and deploying stateless applications • Web frontends and backend APIs • Running isolated environments with imposed CPU/memory limits • …and more!
  • 14. This means that containers are • More lightweight • Can be started, stopped, and restarted more quickly • Easier to migrate • Easier to communicate between containers What’s the difference? Virtual Machines vs Containers
  • 15. Docker Server vs Docker Client Docker server/daemon: The docker server/daemon runs containers within as processes, acting as a virtual bridge to the host operating system (containers are isolated) Docker client: The command line interface (CLI) that is able to connect to the Docker server (specified by the DOCKER_HOST environmental variable) and tell it what to do. This can run on your local machine or on the same host as the Docker server.
  • 22. Installation - Linux curl -fsSL https://get.docker.com/ | sh service docker start Will run a setup script for installing docker Easy setup
  • 23. Installation - Linux apt-get update apt-get purge lxc-docker* apt-get purge docker.io* apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list apt-get -y install apt-transport-https apt-get -y update apt-get -y install docker-engine service docker start Debian/Ubuntu curl https://raw.githubusercontent.com/anonmily/scripts/master/docker-setup-debian | bash Or, just
  • 24. Installation - Linux yum install docker service docker start Fedora curl https://raw.githubusercontent.com/anonmily/scripts/master/docker-setup-yum | bash Or, just
  • 25. Installation – Non-Linux • Download and install the Docker Toolbox https://www.docker.com/docker- toolbox • Open the Docker Quickstart Terminal
  • 27. Docker Server/CLI docker-machine create –driver virtualbox host1 docker-machine create –driver virtualbox host2 docker-machine create –driver virtualbox host3 Create a new docker host docker-machine ls List docker hosts
  • 28. Docker Server/CLI docker-machine stop host1 Stop docker host docker-machine start host1 Start docker host docker-machine restart host1 Restart docker host
  • 29. Docker Server/CLI docker-machine ip host1 Get IP address of host docker-machine env host1 Get environmental variables of the host
  • 30. Docker Server/CLI eval $(docker-machine-env host1) Set environmental variables of CLI to communicate with a host ** If you get a “Cannot connect to the Docker daemon. Is the docker daemon running on this host?” error when attempting to use the Docker CLI, make sure the environmental variables are set for your Docker host
  • 31. Docker Images • Docker images are a saved state of the container. They’re the “golden image” for your containers, and multiple containers based off the same mage can be run at the same time (executing different commands etc in the same environment if necessary) • Image ID = hashed representation of the image, a unique identifier • A Dockerfile is a file that describes all the steps needed to build a Docker image
  • 32. Docker Images • Images can be tagged with a name and a version label (e.g. nginx:latest, ubuntu:14:04) • Images are stored in and can be retrieve from Docker Repositories • Docker Hub: Public repository with common base images • Private Registry: Deploy your own Docker registry
  • 33. Storing Docker Images • Docker registry: A server that hosts your Docker images; it acts in a fashion analogous to repositories in that you can push and pull images from the registry. You can use a public registry like Docker hub, or you can setup your own for private images. • Docker Hub: A public Docker registry that is the default for pulling images. It provides many common base images such as Debian, Ubuntu, Fedora, etc.
  • 35. Deploy your own registry server
  • 37. Docker Images docker pull nginx:latest Pull/get an image (from Docker Hub) # login to DockerHub docker login # private registry docker login https://myownregistry.com:5000 Login to a registry • Docker will save your login credentials in ~/.docker/config.json docker images See your downloaded/available images
  • 38. Docker Images docker build –t webapp1:latest . Build a new image tagged “webapp1:latest” from a Dockerfile docker run --name="myapp" -p 80:80 -d nginx:latest nginx -g "daemon off;" Run a container from an image • --name=“myapp” Run a new container called “myapp” • -p 80:80 Expose port 80 of the host and map it to port 80 of the container • -d Run daemonized • nginx:latest Base image • nginx –g “daemon off;” Command to start the container with
  • 39. Docker Images docker exec –it nodeapp bash Execute a command into a container docker ps # running containers docker ps –a # all containers List containers docker stop nodeapp Stop container docker rm nodeapp Remove container
  • 40. Docker Images docker save myimage:latest > myimage.tar Save an image to a tarball docker import myimage.tar Import an image from a tarball docker commit –m “newconfig” mycontainer myimage:latest Commit/save the current state of a container to the image
  • 41. Docker Images docker rmi myimage:latest Remove an image docker rmi $(docker images –q –f “dangling=true”) Delete all untagged images docker rmi $(docker images –q -) Delete all images on Docker host
  • 42. What is a Dockerfile? • Instructions for how to build a Docker image FROM anonmily/node:latest MAINTAINER Michelle Liu <[email protected]> COPY src/node_modules /src/node_modules COPY certs /src/certs EXPOSE 443 WORKDIR /src ENV PATH /src/bin:$PATH COPY src/bin /src/bin COPY src/app /src/app COPY src/server.js src/app.js src/package.json Makefile /src/ CMD ["startserver"]
  • 43. Anatomy of a Dockerfile • FROM what base image to use for the new image • MAINTAINER who maintains the image • COPY source destination copy files from the source location to destination • ENV set environmental variables • WORKDIR set working directory of the container • CMD run command • EXPOSE indicates what ports should be available for exposure
  • 44. Dockerizing a Node application FROM anonmily/node:latest MAINTAINER Michelle Liu <[email protected]> COPY src/node_modules /src/node_modules COPY certs /src/certs EXPOSE 443 WORKDIR /src ENV PATH /src/bin:$PATH COPY src/bin /src/bin COPY src/app /src/app COPY src/server.js src/app.js src/package.json Makefile /src/ CMD ["startserver"] /Src app/ app.js bin/ startserver certs gulpfile.js node_modules server.js Makefile Bin/ Certs/ Src/ app.js bin/ startserver gulpfile.js node_modules server.js Server.js Production.env Dockerfile Makefile Original Folder Docker Container
  • 45. Utilizing the Layer Cache FROM anonmily/node:latest MAINTAINER Michelle Liu <[email protected]> COPY src/node_modules /src/node_modules COPY certs /src/certs EXPOSE 443 WORKDIR /src ENV PATH /src/bin:$PATH COPY src/bin /src/bin COPY src/app /src/app COPY src/server.js src/app.js src/package.json Makefile /src/ CMD ["startserver"] Least changed files on top More frequently changed files on bottom
  • 46. Building the image # ./bin/buildapi docker build -t myregistry.com/nodeapi:latest . # ./bin/pushapi docker push myregistry.com/nodeapi:latest
  • 47. Updating to a newer image # ./bin/updatecontainer docker pull myregistry.com/nodeapi:latest docker kill nodeapicontainer; docker rm nodeapicontainer; docker run --name nodeapi01 -p 443:443 -dit --env-file /home/production.env myregistry.com/nodeapi:latest startserver
  • 48. An easy way to deploy 1. Push the new image up onto the Docker registry (e.g. 1.0.0) 2. From the servers, pull down the new image 3. Kill the currently running container based off the old outdated image 4. Run a new container based off the new image
  • 49. Updating to a newer image #!/bin/bash docker build -t myregistry.com/nodeapi:latest . docker push myregistry.com/nodeapi:latest ssh -i ~/.ssh/mysshkey [email protected] 'bash' < bin/updatecontainer ssh -i ~/.ssh/mysshkey [email protected] 'bash' < bin/updatecontainer ssh -i ~/.ssh/mysshkey [email protected] 'bash' < bin/updatecontainer
  • 50. Startserver #!/bin/bash pm2 dump pm2 start /src/server.js -i 0 --name nodeapi --no-daemon & If you want to start your container up with more than one command, use a bash script
  • 51. Docker remote API An API for the Docker daemon/server that allows you to make requests to/query the server for creating/editing or for information on containers/images.
  • 52. Docker remote API By default, the Docker daemon will run on the unix port at /var/run/docker.sock. To get started with the Docker remote API, make sure that you have a cURL version greater than 7.40 so that the –unix-socket option is available. Then, we can use curl to interact with the remote API by: curl --unix-socket /var/run/docker.sock http://containers/json
  • 53. Docker remote API It’s also possible to bind the Docker daemon to a TCP port at startup by: docker daemon –H tcp://0.0.0.0:2375 –H /var/run/docker.sock It will then be possible to access the remote API on the host publicly (though it is a security issue). curl http://localhost:2375/containers/json
  • 54. More resources • http://view.dckr.info/DockerIntro.pdf • http://view.dckr.info/DockerAdvanced.pdf • https://docs.docker.com/engine/articles/dockerfile_best-practices/ • http://blog.thoward37.me/articles/where-are-docker-images-stored/ • http://blog.trifork.com/2013/12/24/docker-from-a-distance-the-remote-api/