SlideShare uma empresa Scribd logo
1 de 36
n00b's Guide to Docker
Basic Docker terms & concepts to get you started
Alec Clews
July
2018
Agenda
• What's Docker?
• What are the problems it solves?
• What's an image and a container?
• Show me it working!
• How Can I use it?
This is my personal opinion. Hopefully this will bootstrap you
enough to become dangerous
NOTE: I will not be talking about Windows Docker containers
Who is Alec?
Old school software nerd
Using Linux since kernel 0.99
Works as the technical integration manager
at PaperCut Software
Loves technology, sometimes too much!
(also beer and coffee)
@alecthegeek alecthgeek https://www.linkedin.com/in/alecclews/
What is Docker?
Process isolation framework
Lightweight virtual machines
Easy way to deploy to dev/test/prod consistently
Great way to set up a developer environment
Which does not really mean much….
We need a Simple Model
A software system is a collection of processes and the
resources they need to work to do something useful
A process is code loaded into memory and running on a
processor, plus access to the required resources
Resources are all the different things a process needs. For
example: users; network access; security profiles; files (file
systems); process space; …
Look at PaperCut NG
Database
server
Database
Application
Server
Print
Provider
Files
Processes
ResourcesFiles
Options to run this workload
1. One big machine running everything, it works but...
a. Performance and scalability
b. Wasted CPU resources
c. Complex to provision and maintain all the running parts
d. One process can impact another and can see all
resources
e. Hard to develop on same configuration
Process A Process B Process C
Operating System
Options to run this workload
2. Virtual Machines to isolate processes, better but...
a. Complex to provision and maintain all the machines
b. Hard to develop on same configuration
c. OS overhead
Process A Process B Process C
Host Operating System
Linux O/S on a VM Manager
Virtual Machine Engine
Guest O/S Guest O/S Guest O/S
Options to run this workload
3. Containerisation isolates processes running on single
machine.
Even better (but nothing is ever perfect of course)
Process A Process B Process C
Linux Operating System
Containing Layer
Process Containers running on Linux
Operating-system-level virtualization
a.k.a. containerisation
"operating system feature in which the kernel allows the
existence of multiple isolated user-space instances. Such
instances, called containers, look like real computers from
the point of view of programs running in them. A program
running on an ordinary operating system can see all
resources (connected devices, files and folders, network
shares, CPU power, quantifiable hardware capabilities) of
that computer. However, programs running inside a
container can only see the container's contents and
devices assigned to the container." Wikipedia
What problems can we solve?
• Scalability -- cheap and quick to provision more
workers (& vice versa)
• Resilience -- Process are contained. Failures can be
restarted
• Lower costs -- Fewer resources, easy deployment
• Easy to make dev look like production
– Repeatable build and deployment process
– Fast, low resources
• Cheap and fast test setup & teardown
So Docker eh?
• Docker is the world's most popular containerisation
platform (?)
• Works on the Linux Kernel. Uses Linux specific feature
– But see also Windows Nano Containers
• Ecosystem of tools, scaling technology and info
– E.g. Cubby Kittens Kubernetes
• Watch Liz Rice's video for insight on how it works
under the hood (https://youtu.be/_TsSmSu57Zo)
What is a Docker image?
• It's a bunch of files and metadata required to start &
run a container
– Think "file system + metadata"
• It contains
– Linux packages your program needs to run. E.g. CUPS
– Your program and static config files
– Metadata about access to OS Level resources
(networking, persistent storage, ENV variables,..)
– Default startup command
• IT'S NOT RUNNING PROCESSES
– Just the information you need to start and run them
• It's small!
So what's a Docker container?
• In memory contents of an image that is currently
running in Docker
• One or more processes using resources
• Can only access resources granted to it via Docker
• A CONTAINER CANNOT MODIFY THE IMAGE
(persistently)
• One image can be used to start many containers
Enough Already. SHOW ME!
Let's run an image in a container
There are lots of pre build images ready for us to run
Start with a small lightweight Linux distro -- Alpine
1. Download an Image
• docker image pull alpine
• docker image inspect alpine
1. Run a Container
• docker container run -it --name myAlpine 
alpine /bin/sh
• docker container inspect myAlpine
Container State
The ls & inspect command displays the container state
Usually running, exited or null (not running)
Try
docker container run -it --name myAlpine alpine sh
In another shell window run
docker container ls
and
docker container inspect myAlpine | less
Going from running to exited
From the Alpine shell prompt hit <Ctrl>-C
Should be returned to host prompt
So
docker container ls
BUT
docker container ls -a
and
docker container inspect --format
'{{.State.Status}}' myAlpine
A container that is exited can be
restarted
Carrying from previous example
docker container restart myAlpine
docker container inspect 
--format '{{.State.Status}}' myAlpine
docker container attach myAlpine
A useful alias
The very useful command
docker container inspect --format '{{.State.Status}}' …
is so tedious to type. So create an alias
alias doccs="docker container inspect --format
'{{.State.Status}}'"
Now we can say
doccs myAlpine
Removing a container
Carrying on from previous example
From myAlpine shell prompt hit <Ctrl>-p <Ctrl>-q
Container is now detached, but still running
docker container inspect --format {{.State.Status}}
myAlpine
Stop container
docker container stop myAlpine
docker container inspect --format {{.State.Status}}
myAlpine
Remove container
docker container rm myAlpine
RTFM
More information on different container states in the
Docker API docs
https://docs.docker.com/engine/api/v1.37/#operation/Cont
ainerInspect
More about the container commands at
https://docs.docker.com/engine/reference/commandline/co
ntainer/
Access to container network ports
• Container process is isolated Duh!
• How to access network services on Container?
• Use port mapping
• Maps a containers network port (e.g. 80) to a different
port on the host interface
• For example
docker container run --publish 8089:80 
--name nginx nginx
then open http://0.0.0.0:8089/
Process A Process B Process C
Docker Host (Linux VM)
Containing Layer
Docker on your workstation
Volumes
Mounts MacOS or Windows
Persistence
• When you remove a container you lose any changes
to the file system
• Images are READ ONLY
• SO -- Map storage locations to Data Volumes and
Mount Points
• Volumes and Mounts exist outside the container file
system
• They are linked into the container file system when the
container starts
Bind mount demo
docker container run --publish 8089:80 
--volume $PWD:/usr/share/nginx/html 
--name nginx nginx
Custom image!
Building a custom image takes time, so we will start a build
1st and then explain how it works.
docker image build -f jdk.dockerfile -t jdk
.
Images -- I need a custom image!
• You need an image to run a container
• Lots of nice images -- see https://store.docker.com/
• Sometimes you need something more or different. E.g.
a Java development environment or an application
• How?
1. Write a Dockerfile
2. Run docker build
For example….
Docker file
FROM debian
LABEL maintainer "Alec Clews <alec.clews@papercut.com>"
LABEL description "Linux with JDK"
RUN apt-get update &&
DEBIAN_FRONTEND=noninteractive 
apt-get install --yes openjdk-8-jdk
ENTRYPOINT ["/bin/bash", "-c", "javac -version"]
Now build it
docker image build -f jdk.dockerfile -t jdk
.
What did end up with?
docker image inspect jdk
Name of Dockerfile
Name of new image Build context
Now run it
docker container run --name myJDK jdk
Docker Compose
• The Docker run (& build) tool docker-compose
• It's driven from a Compose file
– And of course it's bloody YAML! 😠
• A single place to put all the different options for each
container e.g.
– publish, mounts, environment variables,
dependencies,...
Look at this example & see it in action
docker-compose -f docker-compose.yml up
More information
I learned a lot from this Udemy course
Docker is sooo HOT right now, so loads of blogs, videos etc
Don't forget to RTFM
Examples used in the demos can be found here
https://github.com/PaperCutSoftware/DockerSimpleDemo
Example shell aliases and functions at
https://gist.github.com/f3l1x/4c3bb59397d976ac83f0 and
https://github.com/tcnksm/docker-alias
Thank
you!
Thank
you!

Mais conteúdo relacionado

Mais procurados

Microservices. Microservices everywhere! (At OSCON 2015)
Microservices. Microservices everywhere! (At OSCON 2015)Microservices. Microservices everywhere! (At OSCON 2015)
Microservices. Microservices everywhere! (At OSCON 2015)
Jérôme Petazzoni
 

Mais procurados (20)

Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker by Example - Quiz
Docker by Example - QuizDocker by Example - Quiz
Docker by Example - Quiz
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGHDeploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
 
Docker
DockerDocker
Docker
 
Optimizing Docker Images
Optimizing Docker ImagesOptimizing Docker Images
Optimizing Docker Images
 
Java Developer Intro to Environment Management with Vagrant, Puppet, and Dock...
Java Developer Intro to Environment Management with Vagrant, Puppet, and Dock...Java Developer Intro to Environment Management with Vagrant, Puppet, and Dock...
Java Developer Intro to Environment Management with Vagrant, Puppet, and Dock...
 
Microservices. Microservices everywhere! (At OSCON 2015)
Microservices. Microservices everywhere! (At OSCON 2015)Microservices. Microservices everywhere! (At OSCON 2015)
Microservices. Microservices everywhere! (At OSCON 2015)
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
Exploring Docker Security
Exploring Docker SecurityExploring Docker Security
Exploring Docker Security
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and Java
 
Docker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing MeetupDocker Tips And Tricks at the Docker Beijing Meetup
Docker Tips And Tricks at the Docker Beijing Meetup
 
Immutable infrastructure with Docker and containers (GlueCon 2015)
Immutable infrastructure with Docker and containers (GlueCon 2015)Immutable infrastructure with Docker and containers (GlueCon 2015)
Immutable infrastructure with Docker and containers (GlueCon 2015)
 
Containers: The What, Why, and How
Containers: The What, Why, and HowContainers: The What, Why, and How
Containers: The What, Why, and How
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
How to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeHow to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker Compose
 
Docker in production: reality, not hype (OSCON 2015)
Docker in production: reality, not hype (OSCON 2015)Docker in production: reality, not hype (OSCON 2015)
Docker in production: reality, not hype (OSCON 2015)
 
Docker, the Future of DevOps
Docker, the Future of DevOpsDocker, the Future of DevOps
Docker, the Future of DevOps
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
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
 

Semelhante a Novices guide to docker

PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
Vipobav
 

Semelhante a Novices guide to docker (20)

Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
Docker & Daily DevOps
Docker & Daily DevOpsDocker & Daily DevOps
Docker & Daily DevOps
 
Docker and-daily-devops
Docker and-daily-devopsDocker and-daily-devops
Docker and-daily-devops
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
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
 
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
PuppetConf 2017: What’s in the Box?!- Leveraging Puppet Enterprise & Docker- ...
 
Containers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific TrioContainers, Docker, and Microservices: the Terrific Trio
Containers, Docker, and Microservices: the Terrific Trio
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
 
Docker containers & the Future of Drupal testing
Docker containers & the Future of Drupal testing Docker containers & the Future of Drupal testing
Docker containers & the Future of Drupal testing
 
Docker-Presentation.pptx
Docker-Presentation.pptxDocker-Presentation.pptx
Docker-Presentation.pptx
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Using Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsUsing Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and Jenkins
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
Docker
DockerDocker
Docker
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
 
Docker get started
Docker get startedDocker get started
Docker get started
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 

Mais de Alec Clews

Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
Alec Clews
 
Novice Programmers Workshop
Novice Programmers WorkshopNovice Programmers Workshop
Novice Programmers Workshop
Alec Clews
 

Mais de Alec Clews (11)

Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
 
Fixing Australian Computer Education
Fixing Australian Computer EducationFixing Australian Computer Education
Fixing Australian Computer Education
 
Novice Programmers Workshop
Novice Programmers WorkshopNovice Programmers Workshop
Novice Programmers Workshop
 
Linux backup
Linux backupLinux backup
Linux backup
 
Software Build processes and Git
Software Build processes and GitSoftware Build processes and Git
Software Build processes and Git
 
Deploy Application Files with Git
Deploy Application Files with GitDeploy Application Files with Git
Deploy Application Files with Git
 
Collaboration With Git and GitHub
Collaboration With Git and GitHubCollaboration With Git and GitHub
Collaboration With Git and GitHub
 
Basic Make
Basic MakeBasic Make
Basic Make
 
Create a better Demo
 Create a better Demo Create a better Demo
Create a better Demo
 
OSDC 2006 Presentaton: Building with a Version Control Audit Trail
OSDC 2006 Presentaton: Building with a Version Control Audit TrailOSDC 2006 Presentaton: Building with a Version Control Audit Trail
OSDC 2006 Presentaton: Building with a Version Control Audit Trail
 
SCM: An Introduction
SCM: An IntroductionSCM: An Introduction
SCM: An Introduction
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 

Novices guide to docker

  • 1. n00b's Guide to Docker Basic Docker terms & concepts to get you started Alec Clews July 2018
  • 2. Agenda • What's Docker? • What are the problems it solves? • What's an image and a container? • Show me it working! • How Can I use it? This is my personal opinion. Hopefully this will bootstrap you enough to become dangerous NOTE: I will not be talking about Windows Docker containers
  • 3. Who is Alec? Old school software nerd Using Linux since kernel 0.99 Works as the technical integration manager at PaperCut Software Loves technology, sometimes too much! (also beer and coffee) @alecthegeek alecthgeek https://www.linkedin.com/in/alecclews/
  • 4. What is Docker? Process isolation framework Lightweight virtual machines Easy way to deploy to dev/test/prod consistently Great way to set up a developer environment Which does not really mean much….
  • 5. We need a Simple Model A software system is a collection of processes and the resources they need to work to do something useful A process is code loaded into memory and running on a processor, plus access to the required resources Resources are all the different things a process needs. For example: users; network access; security profiles; files (file systems); process space; …
  • 6. Look at PaperCut NG Database server Database Application Server Print Provider Files Processes ResourcesFiles
  • 7. Options to run this workload 1. One big machine running everything, it works but... a. Performance and scalability b. Wasted CPU resources c. Complex to provision and maintain all the running parts d. One process can impact another and can see all resources e. Hard to develop on same configuration
  • 8. Process A Process B Process C Operating System
  • 9. Options to run this workload 2. Virtual Machines to isolate processes, better but... a. Complex to provision and maintain all the machines b. Hard to develop on same configuration c. OS overhead
  • 10. Process A Process B Process C Host Operating System Linux O/S on a VM Manager Virtual Machine Engine Guest O/S Guest O/S Guest O/S
  • 11. Options to run this workload 3. Containerisation isolates processes running on single machine. Even better (but nothing is ever perfect of course)
  • 12. Process A Process B Process C Linux Operating System Containing Layer Process Containers running on Linux
  • 13. Operating-system-level virtualization a.k.a. containerisation "operating system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances, called containers, look like real computers from the point of view of programs running in them. A program running on an ordinary operating system can see all resources (connected devices, files and folders, network shares, CPU power, quantifiable hardware capabilities) of that computer. However, programs running inside a container can only see the container's contents and devices assigned to the container." Wikipedia
  • 14. What problems can we solve? • Scalability -- cheap and quick to provision more workers (& vice versa) • Resilience -- Process are contained. Failures can be restarted • Lower costs -- Fewer resources, easy deployment • Easy to make dev look like production – Repeatable build and deployment process – Fast, low resources • Cheap and fast test setup & teardown
  • 15. So Docker eh? • Docker is the world's most popular containerisation platform (?) • Works on the Linux Kernel. Uses Linux specific feature – But see also Windows Nano Containers • Ecosystem of tools, scaling technology and info – E.g. Cubby Kittens Kubernetes • Watch Liz Rice's video for insight on how it works under the hood (https://youtu.be/_TsSmSu57Zo)
  • 16. What is a Docker image? • It's a bunch of files and metadata required to start & run a container – Think "file system + metadata" • It contains – Linux packages your program needs to run. E.g. CUPS – Your program and static config files – Metadata about access to OS Level resources (networking, persistent storage, ENV variables,..) – Default startup command • IT'S NOT RUNNING PROCESSES – Just the information you need to start and run them • It's small!
  • 17. So what's a Docker container? • In memory contents of an image that is currently running in Docker • One or more processes using resources • Can only access resources granted to it via Docker • A CONTAINER CANNOT MODIFY THE IMAGE (persistently) • One image can be used to start many containers
  • 18. Enough Already. SHOW ME! Let's run an image in a container There are lots of pre build images ready for us to run Start with a small lightweight Linux distro -- Alpine 1. Download an Image • docker image pull alpine • docker image inspect alpine 1. Run a Container • docker container run -it --name myAlpine alpine /bin/sh • docker container inspect myAlpine
  • 19. Container State The ls & inspect command displays the container state Usually running, exited or null (not running) Try docker container run -it --name myAlpine alpine sh In another shell window run docker container ls and docker container inspect myAlpine | less
  • 20. Going from running to exited From the Alpine shell prompt hit <Ctrl>-C Should be returned to host prompt So docker container ls BUT docker container ls -a and docker container inspect --format '{{.State.Status}}' myAlpine
  • 21. A container that is exited can be restarted Carrying from previous example docker container restart myAlpine docker container inspect --format '{{.State.Status}}' myAlpine docker container attach myAlpine
  • 22. A useful alias The very useful command docker container inspect --format '{{.State.Status}}' … is so tedious to type. So create an alias alias doccs="docker container inspect --format '{{.State.Status}}'" Now we can say doccs myAlpine
  • 23. Removing a container Carrying on from previous example From myAlpine shell prompt hit <Ctrl>-p <Ctrl>-q Container is now detached, but still running docker container inspect --format {{.State.Status}} myAlpine Stop container docker container stop myAlpine docker container inspect --format {{.State.Status}} myAlpine Remove container docker container rm myAlpine
  • 24. RTFM More information on different container states in the Docker API docs https://docs.docker.com/engine/api/v1.37/#operation/Cont ainerInspect More about the container commands at https://docs.docker.com/engine/reference/commandline/co ntainer/
  • 25. Access to container network ports • Container process is isolated Duh! • How to access network services on Container? • Use port mapping • Maps a containers network port (e.g. 80) to a different port on the host interface • For example docker container run --publish 8089:80 --name nginx nginx then open http://0.0.0.0:8089/
  • 26. Process A Process B Process C Docker Host (Linux VM) Containing Layer Docker on your workstation Volumes Mounts MacOS or Windows
  • 27. Persistence • When you remove a container you lose any changes to the file system • Images are READ ONLY • SO -- Map storage locations to Data Volumes and Mount Points • Volumes and Mounts exist outside the container file system • They are linked into the container file system when the container starts
  • 28. Bind mount demo docker container run --publish 8089:80 --volume $PWD:/usr/share/nginx/html --name nginx nginx
  • 29. Custom image! Building a custom image takes time, so we will start a build 1st and then explain how it works. docker image build -f jdk.dockerfile -t jdk .
  • 30. Images -- I need a custom image! • You need an image to run a container • Lots of nice images -- see https://store.docker.com/ • Sometimes you need something more or different. E.g. a Java development environment or an application • How? 1. Write a Dockerfile 2. Run docker build For example….
  • 31. Docker file FROM debian LABEL maintainer "Alec Clews <alec.clews@papercut.com>" LABEL description "Linux with JDK" RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --yes openjdk-8-jdk ENTRYPOINT ["/bin/bash", "-c", "javac -version"]
  • 32. Now build it docker image build -f jdk.dockerfile -t jdk . What did end up with? docker image inspect jdk Name of Dockerfile Name of new image Build context
  • 33. Now run it docker container run --name myJDK jdk
  • 34. Docker Compose • The Docker run (& build) tool docker-compose • It's driven from a Compose file – And of course it's bloody YAML! 😠 • A single place to put all the different options for each container e.g. – publish, mounts, environment variables, dependencies,... Look at this example & see it in action docker-compose -f docker-compose.yml up
  • 35. More information I learned a lot from this Udemy course Docker is sooo HOT right now, so loads of blogs, videos etc Don't forget to RTFM Examples used in the demos can be found here https://github.com/PaperCutSoftware/DockerSimpleDemo Example shell aliases and functions at https://gist.github.com/f3l1x/4c3bb59397d976ac83f0 and https://github.com/tcnksm/docker-alias