SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
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/

Weitere ähnliche Inhalte

Was ist angesagt?

Docker
DockerDocker
DockerChen Chun
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionJeffrey Ellin
 
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 DockerJĂ©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 ContainerBalaji Rajan
 
Docker Basics
Docker BasicsDocker Basics
Docker BasicsDuckDuckGo
 
Docker : Container Virtualization
Docker : Container VirtualizationDocker : Container Virtualization
Docker : Container VirtualizationRanjan Baisak
 
Docker Basic Presentation
Docker Basic PresentationDocker Basic Presentation
Docker Basic PresentationAman Chhabra
 
Docker for developers
Docker for developersDocker for developers
Docker for developersandrzejsydor
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX ContainerAraf Karsh Hamid
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter PackSaeed Hajizade
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebrationRamon Morales
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basicsWalid 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 fundamentalsAlper 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 DeploymentsBen 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-12dotCloud
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystempsconnolly
 

Was ist angesagt? (20)

Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
 
Docker
DockerDocker
Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
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
 
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...
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker : Container Virtualization
Docker : Container VirtualizationDocker : Container Virtualization
Docker : Container Virtualization
 
Docker Basic Presentation
Docker Basic PresentationDocker Basic Presentation
Docker Basic Presentation
 
Docker for developers
Docker for developersDocker for developers
Docker for developers
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebration
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
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...
 
Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
 
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
 
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
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 

Ă„hnlich wie Up and running with docker

Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptxVipobav
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101Naukri.com
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes IstioAraf Karsh Hamid
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From ScratchGiacomo Vacca
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and MicroserviceSamuel Chow
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for DevelopersJasonStraughan1
 
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 Herofazalraja
 
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 BengaluruSwaminathan Vetri
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessDocker-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.pptaravym456
 
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-2021Alessandro Mignogna
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolboxYonghwee Kim
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerGuido Schmutz
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET DevelopersTaswar Bhatti
 

Ă„hnlich wie Up and running with docker (20)

Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Docker and Microservice
Docker and MicroserviceDocker and Microservice
Docker and Microservice
 
How to _docker
How to _dockerHow to _docker
How to _docker
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Docker 1.9 Workshop
Docker 1.9 WorkshopDocker 1.9 Workshop
Docker 1.9 Workshop
 
Docker slides
Docker slidesDocker slides
Docker slides
 
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
 
Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker @ Atlogys
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
 
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
 
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
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET Developers
 

KĂĽrzlich hochgeladen

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 

KĂĽrzlich hochgeladen (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 

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 <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"]
  • 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 <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
  • 45. 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
  • 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 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
  • 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/