![Page 1: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/1.jpg)
PSF 11/05/20191
Hands-On WithDocker Containers
Peter Fales
NWCLUG
November 5, 2019
![Page 2: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/2.jpg)
PSF 11/05/20192
Topics● Overview of Docker
– Intro for new users – focus is on high level, introduce concepts, whet your appetite
● Motivation – why Docker● Basic Concepts● Demo of basic concepts and operations
– Install Docker, start containers, create custom images, etc..
![Page 3: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/3.jpg)
PSF 11/05/20193
What is Docker● Virtualized container execution environment
– Builds on native linux facilities: cgroups, namespaces, networks, etc. for resource prioritization, limitation, and isolation
● Application deployment engine– Simplifies creation, distribution, execution of
virtual images– Shipping container paradigm
![Page 4: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/4.jpg)
PSF 11/05/20194
Docker (Container) vs. VM
![Page 5: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/5.jpg)
PSF 11/05/20195
Why Docker?● Goals
– Lightweight, fast, easy to use– Logical segregation, enhance consistency
(reduce “it worked in dev”)– Reduce development cycle time– Encourages (but does not require)
“microservices” architecture (modularity)– Layering allows for version control and
rollback
![Page 6: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/6.jpg)
PSF 11/05/20196
Concepts● Docker client and server (Docker Engine)● Images● Containers● Registries/Repositories● Dockerfile● Volumes● Networking
![Page 7: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/7.jpg)
PSF 11/05/20197
Docker Client and Server
● Heavy lifting done by server, dockerd, aka Docker Engine
– Manages images and containers● Controlled from:
– Command line client, docker, either on local machine or over network
– Restful API
![Page 8: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/8.jpg)
PSF 11/05/20198
Docker Images● Building blocks or “source code” for containers● Layered using Union file systems
– Add a file– Open a port– And lots more...
● Can be built interactively, but more typically● Built from a “recipe” in a Dockerfile
– Ensures that images are complete, consistent, and correct
![Page 9: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/9.jpg)
PSF 11/05/20199
Docker Containers
● Running instance of an image● Multiple containers can run from one image● Concept comes from standard shipping container:
– Standard operations (create, start, stop)– Unique contents
![Page 10: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/10.jpg)
PSF 11/05/201910
Docker Containers
https://www.docker.com/sites/default/files/Package%20software.png
![Page 11: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/11.jpg)
PSF 11/05/201911
Registries/Repositories● Centralized storage of images● Facilitates sharing and distribution● Can be
– Public (e.g. docker.com/docker.io) – Default if not otherwise specified
– Private – Privately hosted, or docker.com● Named as host:port/namespace/image:
FULL: localhost:5000/psfales/my_image OR WITH DEFAULTS: ubuntu
![Page 12: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/12.jpg)
PSF 11/05/201912
Dockerfile● Step-by-step “recipe” for building a image● Each step is a layer – caching can speed up rebuild
process● Numerous commands: ADD, RUN, EXPOSE, ENV, etc.
FROM httpdMAINTAINER Peter FalesRUN apt-get updateADD index.html /usr/local/apache2/htdocs
![Page 13: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/13.jpg)
PSF 11/05/201913
Volumes
● Makes a directory outside the container visible to the container
– Permanent Data Store– Shared access from container and host
● Two types of Volumes– Native (host) file system– Volume Containers
![Page 14: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/14.jpg)
PSF 11/05/201914
Networking
● Very powerful & flexible – can be complex, but easy to get started
– Expose ports to the outside (non-Docker) world– Link connectors via internal ports or named
hosts– Overlay network extends over multiple hosts– Other mechanisms managed by Orchestration
systems
![Page 15: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/15.jpg)
PSF 11/05/201915
Orchestration (examples)● Docker Compose – create application stacks (web server,
application server, database)
● Docker Swarm - create scalable clusters
● Docker-machine – alternative for managing machines and clusters, including cloud services
● Apache Mesos - “A distributed systems kernel” - API’s for resource management and scheduling across entire datacenter and cloud environments.
● Google Kubernetes - an open-source system for automating deployment, scaling, and management of containerized applications.
![Page 16: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/16.jpg)
PSF 11/05/201916
Why?
● Detailed recipes ensure consistency over time, or between development, test, and production (“Run anywhere”)
● Consistent environment – develop on desktop, deploy on cloud
● Lightweight – quick development cycle, not resource intensive
![Page 17: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/17.jpg)
PSF 11/05/201917
Why not?● If you need kernel modifications
● If you need cross-platform (e.g. IIS, or other applications that run only on Windows)
● If you need rich user interfaces, such as X (but workarounds)
● May be ephemeral (workarounds)
● May increase security attack space
● Performance limitations of Union file system. (workarounds)
http://www.channelfutures.com/open-source/when-not-use-docker-understanding-limitations-containers
![Page 18: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/18.jpg)
PSF 11/05/201918
Docker Environments
● Linux host running Ubuntu, Debian, RHEL, CentOS, Scientific Linux, Fedora, or others
● OS X using “Docker for Mac” (virtual machine)● Microsoft Windows using “Docker for Windows” (virtual
machine)
![Page 19: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/19.jpg)
PSF 11/05/201919
Installation on Fedora● Install Docker
# yum -y install docker
● Start Docker# systemctl start docker
● Enable at boot time# systemctl enable docker
● Test# docker infoContainers: 0Images: 0...
![Page 20: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/20.jpg)
PSF 11/05/201920
Resources
● https://docs.docker.com/articles/dockerfile_best-practices/
● https://www.packtpub.com/networking-and-servers/learning-docker-second-edition
● https://www.dockerbook.com/ ● https://github.com/wsargent/docker-cheat-sheet
![Page 21: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/21.jpg)
PSF 11/05/201921
Live Demo
![Page 22: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/22.jpg)
PSF 11/05/201922
Videos
● DOCKER Intro (8 minutes)https://www.youtube.com/watch?v=pGYAg7TMmp0
● DOCKER Web Server (9 minutes)https://www.youtube.com/watch?v=JBtWxj9l7zM
● KUBERNETES (6.5 minutes)
https://www.youtube.com/watch?v=R-3dfURb2hA
![Page 23: Hands-On With Docker Containers - NWCLUGnwclug.org/demos/191105/Docker.pdfPSF 11/05/2019 2 Topics Overview of Docker – Intro for new users – focus is on high level, introduce concepts,](https://reader035.vdocument.in/reader035/viewer/2022062505/5ec55290b0ce712e771402c6/html5/thumbnails/23.jpg)
PSF 11/05/201923
Q & A