SlideShare una empresa de Scribd logo
1 de 37
Descargar para leer sin conexión
Docker Storage
Introduction
http://bit.ly/2EzR13M
ejlp12@gmail.com
Container Immutability
● The data doesn’t persist when that container no longer exists.
● A container’s writable layer is tightly coupled to the host machine where the
container is running.
● Not easy move the data somewhere else.
● Writing into requires a storage driver to manage the filesystem.
This extra abstraction reduces performance as compared to using data
volumes, which write directly to the host filesystem.
Where are docker images stored
/var/lib/docker
● It stores images (data) and metadata in different
folder
● The content is depend on the storage driver
● Different OS different default storage driver
● You can change storage driver used by Docker
daemon
Storage Drivers:
● aufs
● btrfs
● devicemapper
● vfs
● zfs
● overlay
● overlay2
Storage in Docker (Concept)
Union File System
Union mounting concept:
a way of combining multiple directories
into one that appears to contain their
combined contents.
-- wikipedia
Graph Driver
“graph drivers” is interface (API) to
make storage in Docker pluggable.
Because Docker modeled the images
and the relationship of images to
various layers in a graph and the
filesystems mostly stored images.
Choose Storage Driver based on your workload
● overlay2, aufs, and overlay all operate at the file level rather than the block level. This uses
memory more efficiently, but the container’s writable layer may grow quite large in write-heavy
workloads.
● Block-level storage drivers such as devicemapper, btrfs, and zfs perform better for write-heavy
workloads (though not as well as Docker volumes).
● For lots of small writes or containers with many layers or deep filesystems, overlay may perform
better than overlay2, but consumes more inodes, which can lead to inode exhaustion.
● btrfs and zfs require a lot of memory.
● zfs is a good choice for high-density workloads such as PaaS.
Why so many storage divers?
In order to provide Docker to a broader user base on a variety of distros,
we decided that filesystem support in Docker needs to be pluggable.
https://blog.mobyproject.org/where-are-containerds-graph-drivers-145fc9b7255
Choose stable Storage Driver
The choices with the highest stability:
● overlay2
● aufs
● overlay, and
● devicemapper
View
Storage Driver
Detail Information
An Image
Storage driver handles the details about
the way these layers interact with each
other
all type of drivers use stackable image
layers and the copy-on-write (CoW)
strategy
bootfs
kernel
Base image
Image
Image
W
ritable
Container
add
nginx
add
nodejs
U
buntu
References
parent
image
What is Copy on Write
Copy-on-write is a strategy of sharing and copying files for maximum efficiency
It save space, and also reduces start-up time.
The data appears to be a copy, but is only a link (or reference) to the original data.
The actual copy happens only when someone tries to change the shared data.
Whoever changes the shared data ends up sharing their own copy instead.
http://jpetazzo.github.io/assets/2015-07-01-deep-dive-into-docker-storage-drivers.html#11
A Container instance
All writes to the container that add
new or modify existing data are
stored in a writable layer
When the container is deleted, the
writable layer is also deleted
Writable layer is a THIN Layer
For write-heavy applications, do not
store the data in the container.
Use Docker volume instead.
d798b9381281 0 B
0824f8a0823c 1.895 B
c20113c83319 194.5 B
d3a1f42e8a5a 188.1 MB
When multiple same containers instance are running
read-only layers can be shared
between any container that is
started from the same image
“writable” layer is unique per
container
d798b9381281 0 B
0824f8a0823c 1.895 B
c20113c83319 194.5 B
d3a1f42e8a5a 188.1 MB
FROM node:argon
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
Instruction in
the Dockerfile
adds a layer
to the image
Data Volume
Way to store data
Options for containers to store files in the host machine:
1. volumes (persisted on disk)
stored in a part of the host filesystem which is managed by Docker
(/var/lib/docker/volumes/ on Linux)
2. bind mounts (persisted on disk)
stored anywhere on the host system
3. tmpfs mounts (not persisted on disk & Linux only)
volume
docker volume create myvol
docker run -d 
--name devtest 
--mount source=myvol,target=/app 
nginx:latest
docker run -d 
--name devtest 
-v myvol:/app 
nginx:lates
Using --mount
Using -v
Store file in remote host using sshfs
docker plugin install --grant-all-permissions vieux/sshfs
docker volume create --driver vieux/sshfs 
-o sshcmd=test@node2:/home/test 
-o password=testpassword 
sshvolume
Store file in remote host using NFS
Mount the NFS share on the host and pass it into the container as a host volume:
you@host > mount server:/dir /path/to/mount/point
you@host > docker run -v /path/to/mount/point:/path/to/mount/point
Use service
docker service create -d 
--name nfs-service 
--mount
'type=volume,source=nfsvolume,target=/app,volume-driver=local,volume-opt=type=nfs,vol
ume-opt=device=:/,"volume-opt=o=10.0.0.10,rw,nfsvers=4,async"' 
nginx:latest
Binds mounts
docker run -d 
-it 
--name devtest 
--mount type=bind,source="$(pwd)"/target,target=/app 
nginx:latest
docker run -d 
-it 
--name devtest 
-v "$(pwd)"/target:/app 
nginx:latest
Using --mount
Using -v
tmpfs
docker run -d 
-it 
--name tmptest 
--mount type=tmpfs,destination=/app 
nginx:latest
docker run -d 
-it 
--name tmptest 
--tmpfs /app 
nginx:latest
Using --mount
Using -v
Strategies to Manage Persistent Data
It is recommended to isolate the data from a container to
retain the benefits of adopting containerization.
Data management should be distinctly separate from the
container lifecycle.
https://thenewstack.io/methods-dealing-container-storage/
Strategies to Manage Persistent Data
1. Host-Based Persistence
a. Implicit Per-Container Storage (Volume)
b. Explicit Shared Storage (Bind mounts)
c. Shared Multi-Host Storage
2. Volume Plugins
3. Container Storage Ecosystem
a. Software-Defined Storage Providers
b. Storage Appliance Providers
c. Object and Block Storage Providers
https://thenewstack.io/methods-dealing-container-storage/
Storage solution for Container
Ceph, GlusterFS, Network File System (NFS)
ClusterHQ's Flocker, Rancher's Convoy, EMC's REX-Ray, Huawei's Fuxi
Portworx, Hedvig, CoreOS Torus, EMC libStorage, Joyent Manta and Blockbridge
StorageOS, Robin Systems and Quobyte
Resources for deep dive
1. https://docs.docker.com/storage/
2. Deep dive into Docker storage drivers [Jerome Petazzoni]
a. Video - https://www.youtube.com/watch?v=9oh_M11-foU
b. Presentation Slides -
3. https://integratedcode.us/2016/08/30/storage-drivers-in-docker-a-deep-dive/
4. https://thenewstack.io/methods-dealing-container-storage/
5. https://blog.mobyproject.org/where-are-containerds-graph-drivers-145fc9b7255
6. https://blog.jessfraz.com/post/the-brutally-honest-guide-to-docker-graphdrivers/
Thank You
Container Image
Container image
Container Image formats:
● Docker,
● Appc (App Container) used by rkt
● LXD
A standard governed under the Open Container Initiative (OCI):
Container Image Format Specification
What is the content of container image?
OCI image format defines a container image composed of
● tar files for each layer, and
● a manifest file with the metadata (index.json or manifest.json in Docker)
Manifest file
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 190,
"digest": "sha256:efe184abb97e76d7d900b2e97171cc20830b6b1b0e0fe504a4ee7097a6b5c91b"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 170,
"digest": "sha256:9964c16915b8956cb01eb77028b1fd1976287b5ec87cc1663844a0bd32933a47"
}
]
}
Can we merge/flatten layers become a single layer?
Yes, run the image first to load all layers as a container instance then export-import
docker run --name mycontainer
docker export --output=mycontainer.tar mycontainer
cat mycontainer.tar | docker import - mynewimage:imported
Can we merge/flatten layers become a single layer?
Yes, run container then use docker commit
docker commit <container id> <new image name>
Example: Commit a container with new CMD and EXPOSE instructions
docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' 
-c "EXPOSE 80" c3f279d17e0a ejlp12/testimage:version4
Docker Image Tools
● docker-squash a utility to squash multiple docker layers into one in order to
create an image with fewer and smaller layers
● wagoodman/dive a tool for exploring each layer in a docker image
// TODO: add more tools here
Container Image Build Tools
● Jib builds Docker and OCI images in Java
● Kaniko builds images in Kubernetes using a Dockerfile
● rules_docker provides Bazel rules for building images
● BuildKit is the underlying engine used by Docker to build images
● img provides a standalone frontend for BuildKit
● buildah builds OCI images
Multi-stage build
Docker > 17.5
//TODO: Explain multi-stage build here
Storage use-cases and properties
Storage
Type
Description Storage
Fit
Amount
of data
Latency Examples
Block ● Presented to the operating system (OS) as a block
device
● Suitable for applications that need full control of
storage and operate at a low level on files bypassing
the file system
● Also referred to as a Storage Area Network (SAN)
● Non-shareable, which means that only one client at a
time can mount an endpoint of this type
High performance,
primary/secondary
Med Very low Structured, transactional, Relational
DBs.
GlusterFS, iSCSI, Fibre Channel,
Ceph RBD, OpenStack Cinder,
Dell/EMC Scale.IO, VMware vSphere
Volume, GCE Persistent Disk, Azure
Disk, AWS EBS
File ● Presented to the OS as a file system export to be
mounted
● Also referred to as Network Attached Storage (NAS)
● Concurrency, latency, file locking mechanisms, and
other capabilities vary widely between protocols,
implementations, vendors, and scales.
Capacity based
secondary
Low Trade-off
latency for
simplicity
Unstructured, file backup, archival
GlusterFS, RHEL NFS, NetApp NFS,
Azure File, Vendor NFS, Vendor
GlusterFS, Azure File, AWS EFS
Object ● Accessible through a REST API endpoint
● Configurable for use in the OpenShift Container
Platform Registry
● Applications must build their drivers into the
application and/or container.
Highly reliable,
cloud-scale,
primary/secondary
High Low-med Unstructured, big-data analytics
GlusterFS, Ceph Object Storage
(RADOS Gateway), OpenStack Swift,
Aliyun OSS, AWS S3, Google Cloud
Storage, Azure Blob Storage,
Vendor S3, Vendor Swift

Más contenido relacionado

La actualidad más candente

What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
Simplilearn
 
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 Compose by Aanand Prasad
Docker Compose by Aanand Prasad Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad
Docker, Inc.
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
Docker, Inc.
 

La actualidad más candente (20)

Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
Intro to containerization
Intro to containerizationIntro to containerization
Intro to containerization
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
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 Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad Docker Compose by Aanand Prasad
Docker Compose by Aanand Prasad
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Dockerfile
Dockerfile Dockerfile
Dockerfile
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
 

Similar a Introduction to Docker storage, volume and image

Similar a Introduction to Docker storage, volume and image (20)

Cloud Native Computing - Part III - Containers
Cloud Native Computing - Part III - ContainersCloud Native Computing - Part III - Containers
Cloud Native Computing - Part III - Containers
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with Docker
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with Docker
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
 
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...
 
Docker introduction for Carbon IT
Docker introduction for Carbon ITDocker introduction for Carbon IT
Docker introduction for Carbon IT
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
The internals and the latest trends of container runtimes
The internals and the latest trends of container runtimesThe internals and the latest trends of container runtimes
The internals and the latest trends of container runtimes
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
 
Docker on Power Systems
Docker on Power SystemsDocker on Power Systems
Docker on Power Systems
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
Docker training
Docker trainingDocker training
Docker training
 
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
Dev opsec dockerimage_patch_n_lifecyclemanagement_2019
 
Techtalks: taking docker to production
Techtalks: taking docker to productionTechtalks: taking docker to production
Techtalks: taking docker to production
 
JOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to ProductionJOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to Production
 
Docker Overview
Docker OverviewDocker Overview
Docker Overview
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
 

Más de ejlp12

Arah pengembangan core network architecture (Indonesia)
Arah pengembangan core network architecture (Indonesia)Arah pengembangan core network architecture (Indonesia)
Arah pengembangan core network architecture (Indonesia)
ejlp12
 
Agile & SCRUM
Agile & SCRUMAgile & SCRUM
Agile & SCRUM
ejlp12
 

Más de ejlp12 (20)

Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dump
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
WebSphere Application Server Information Resources
WebSphere Application Server Information ResourcesWebSphere Application Server Information Resources
WebSphere Application Server Information Resources
 
WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)WebSphere Application Server Family (Editions Comparison)
WebSphere Application Server Family (Editions Comparison)
 
Linux container & docker
Linux container & dockerLinux container & docker
Linux container & docker
 
BPEL, BPEL vs ESB (Integration)
BPEL, BPEL vs ESB (Integration)BPEL, BPEL vs ESB (Integration)
BPEL, BPEL vs ESB (Integration)
 
BPMN Introduction
BPMN IntroductionBPMN Introduction
BPMN Introduction
 
JBoss Data Virtualization (JDV) Sample Physical Deployment Architecture
JBoss Data Virtualization (JDV) Sample Physical Deployment ArchitectureJBoss Data Virtualization (JDV) Sample Physical Deployment Architecture
JBoss Data Virtualization (JDV) Sample Physical Deployment Architecture
 
WebSphere Application Server Topology Options
WebSphere Application Server Topology OptionsWebSphere Application Server Topology Options
WebSphere Application Server Topology Options
 
IBM WebSphere Application Server version to version comparison
IBM WebSphere Application Server version to version comparisonIBM WebSphere Application Server version to version comparison
IBM WebSphere Application Server version to version comparison
 
IBM WebSphere Application Server (Clustering) Concept
IBM WebSphere Application Server (Clustering) ConceptIBM WebSphere Application Server (Clustering) Concept
IBM WebSphere Application Server (Clustering) Concept
 
IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
 
Introduction to jQuery Mobile
Introduction to jQuery MobileIntroduction to jQuery Mobile
Introduction to jQuery Mobile
 
Introduction to JPA (JPA version 2.0)
Introduction to JPA (JPA version 2.0)Introduction to JPA (JPA version 2.0)
Introduction to JPA (JPA version 2.0)
 
Introduction to JavaBeans Activation Framework v1.1
Introduction to JavaBeans Activation Framework v1.1Introduction to JavaBeans Activation Framework v1.1
Introduction to JavaBeans Activation Framework v1.1
 
Arah pengembangan core network architecture (Indonesia)
Arah pengembangan core network architecture (Indonesia)Arah pengembangan core network architecture (Indonesia)
Arah pengembangan core network architecture (Indonesia)
 
GSM/UMTS network architecture tutorial (Indonesia)
GSM/UMTS network architecture tutorial (Indonesia)GSM/UMTS network architecture tutorial (Indonesia)
GSM/UMTS network architecture tutorial (Indonesia)
 
Agile & SCRUM
Agile & SCRUMAgile & SCRUM
Agile & SCRUM
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+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
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Último (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%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
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
+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...
 
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
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

Introduction to Docker storage, volume and image

  • 2. Container Immutability ● The data doesn’t persist when that container no longer exists. ● A container’s writable layer is tightly coupled to the host machine where the container is running. ● Not easy move the data somewhere else. ● Writing into requires a storage driver to manage the filesystem. This extra abstraction reduces performance as compared to using data volumes, which write directly to the host filesystem.
  • 3. Where are docker images stored /var/lib/docker ● It stores images (data) and metadata in different folder ● The content is depend on the storage driver ● Different OS different default storage driver ● You can change storage driver used by Docker daemon Storage Drivers: ● aufs ● btrfs ● devicemapper ● vfs ● zfs ● overlay ● overlay2
  • 4. Storage in Docker (Concept) Union File System Union mounting concept: a way of combining multiple directories into one that appears to contain their combined contents. -- wikipedia Graph Driver “graph drivers” is interface (API) to make storage in Docker pluggable. Because Docker modeled the images and the relationship of images to various layers in a graph and the filesystems mostly stored images.
  • 5. Choose Storage Driver based on your workload ● overlay2, aufs, and overlay all operate at the file level rather than the block level. This uses memory more efficiently, but the container’s writable layer may grow quite large in write-heavy workloads. ● Block-level storage drivers such as devicemapper, btrfs, and zfs perform better for write-heavy workloads (though not as well as Docker volumes). ● For lots of small writes or containers with many layers or deep filesystems, overlay may perform better than overlay2, but consumes more inodes, which can lead to inode exhaustion. ● btrfs and zfs require a lot of memory. ● zfs is a good choice for high-density workloads such as PaaS.
  • 6. Why so many storage divers? In order to provide Docker to a broader user base on a variety of distros, we decided that filesystem support in Docker needs to be pluggable. https://blog.mobyproject.org/where-are-containerds-graph-drivers-145fc9b7255
  • 7. Choose stable Storage Driver The choices with the highest stability: ● overlay2 ● aufs ● overlay, and ● devicemapper
  • 9. An Image Storage driver handles the details about the way these layers interact with each other all type of drivers use stackable image layers and the copy-on-write (CoW) strategy bootfs kernel Base image Image Image W ritable Container add nginx add nodejs U buntu References parent image
  • 10. What is Copy on Write Copy-on-write is a strategy of sharing and copying files for maximum efficiency It save space, and also reduces start-up time. The data appears to be a copy, but is only a link (or reference) to the original data. The actual copy happens only when someone tries to change the shared data. Whoever changes the shared data ends up sharing their own copy instead. http://jpetazzo.github.io/assets/2015-07-01-deep-dive-into-docker-storage-drivers.html#11
  • 11. A Container instance All writes to the container that add new or modify existing data are stored in a writable layer When the container is deleted, the writable layer is also deleted Writable layer is a THIN Layer For write-heavy applications, do not store the data in the container. Use Docker volume instead. d798b9381281 0 B 0824f8a0823c 1.895 B c20113c83319 194.5 B d3a1f42e8a5a 188.1 MB
  • 12. When multiple same containers instance are running read-only layers can be shared between any container that is started from the same image “writable” layer is unique per container d798b9381281 0 B 0824f8a0823c 1.895 B c20113c83319 194.5 B d3a1f42e8a5a 188.1 MB
  • 13. FROM node:argon # Create app directory RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # Install app dependencies COPY package.json /usr/src/app/ RUN npm install # Bundle app source COPY . /usr/src/app EXPOSE 8080 CMD [ "npm", "start" ] Instruction in the Dockerfile adds a layer to the image
  • 15. Way to store data Options for containers to store files in the host machine: 1. volumes (persisted on disk) stored in a part of the host filesystem which is managed by Docker (/var/lib/docker/volumes/ on Linux) 2. bind mounts (persisted on disk) stored anywhere on the host system 3. tmpfs mounts (not persisted on disk & Linux only)
  • 16. volume docker volume create myvol docker run -d --name devtest --mount source=myvol,target=/app nginx:latest docker run -d --name devtest -v myvol:/app nginx:lates Using --mount Using -v
  • 17. Store file in remote host using sshfs docker plugin install --grant-all-permissions vieux/sshfs docker volume create --driver vieux/sshfs -o sshcmd=test@node2:/home/test -o password=testpassword sshvolume
  • 18. Store file in remote host using NFS Mount the NFS share on the host and pass it into the container as a host volume: you@host > mount server:/dir /path/to/mount/point you@host > docker run -v /path/to/mount/point:/path/to/mount/point Use service docker service create -d --name nfs-service --mount 'type=volume,source=nfsvolume,target=/app,volume-driver=local,volume-opt=type=nfs,vol ume-opt=device=:/,"volume-opt=o=10.0.0.10,rw,nfsvers=4,async"' nginx:latest
  • 19. Binds mounts docker run -d -it --name devtest --mount type=bind,source="$(pwd)"/target,target=/app nginx:latest docker run -d -it --name devtest -v "$(pwd)"/target:/app nginx:latest Using --mount Using -v
  • 20. tmpfs docker run -d -it --name tmptest --mount type=tmpfs,destination=/app nginx:latest docker run -d -it --name tmptest --tmpfs /app nginx:latest Using --mount Using -v
  • 21. Strategies to Manage Persistent Data
  • 22. It is recommended to isolate the data from a container to retain the benefits of adopting containerization. Data management should be distinctly separate from the container lifecycle. https://thenewstack.io/methods-dealing-container-storage/
  • 23. Strategies to Manage Persistent Data 1. Host-Based Persistence a. Implicit Per-Container Storage (Volume) b. Explicit Shared Storage (Bind mounts) c. Shared Multi-Host Storage 2. Volume Plugins 3. Container Storage Ecosystem a. Software-Defined Storage Providers b. Storage Appliance Providers c. Object and Block Storage Providers https://thenewstack.io/methods-dealing-container-storage/
  • 24. Storage solution for Container Ceph, GlusterFS, Network File System (NFS) ClusterHQ's Flocker, Rancher's Convoy, EMC's REX-Ray, Huawei's Fuxi Portworx, Hedvig, CoreOS Torus, EMC libStorage, Joyent Manta and Blockbridge StorageOS, Robin Systems and Quobyte
  • 25. Resources for deep dive 1. https://docs.docker.com/storage/ 2. Deep dive into Docker storage drivers [Jerome Petazzoni] a. Video - https://www.youtube.com/watch?v=9oh_M11-foU b. Presentation Slides - 3. https://integratedcode.us/2016/08/30/storage-drivers-in-docker-a-deep-dive/ 4. https://thenewstack.io/methods-dealing-container-storage/ 5. https://blog.mobyproject.org/where-are-containerds-graph-drivers-145fc9b7255 6. https://blog.jessfraz.com/post/the-brutally-honest-guide-to-docker-graphdrivers/
  • 28. Container image Container Image formats: ● Docker, ● Appc (App Container) used by rkt ● LXD A standard governed under the Open Container Initiative (OCI): Container Image Format Specification
  • 29. What is the content of container image? OCI image format defines a container image composed of ● tar files for each layer, and ● a manifest file with the metadata (index.json or manifest.json in Docker)
  • 30. Manifest file { "schemaVersion": 2, "mediaType": "application/vnd.docker.distribution.manifest.v2+json", "config": { "mediaType": "application/vnd.docker.container.image.v1+json", "size": 190, "digest": "sha256:efe184abb97e76d7d900b2e97171cc20830b6b1b0e0fe504a4ee7097a6b5c91b" }, "layers": [ { "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip", "size": 170, "digest": "sha256:9964c16915b8956cb01eb77028b1fd1976287b5ec87cc1663844a0bd32933a47" } ] }
  • 31. Can we merge/flatten layers become a single layer? Yes, run the image first to load all layers as a container instance then export-import docker run --name mycontainer docker export --output=mycontainer.tar mycontainer cat mycontainer.tar | docker import - mynewimage:imported
  • 32. Can we merge/flatten layers become a single layer? Yes, run container then use docker commit docker commit <container id> <new image name> Example: Commit a container with new CMD and EXPOSE instructions docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a ejlp12/testimage:version4
  • 33. Docker Image Tools ● docker-squash a utility to squash multiple docker layers into one in order to create an image with fewer and smaller layers ● wagoodman/dive a tool for exploring each layer in a docker image // TODO: add more tools here
  • 34. Container Image Build Tools ● Jib builds Docker and OCI images in Java ● Kaniko builds images in Kubernetes using a Dockerfile ● rules_docker provides Bazel rules for building images ● BuildKit is the underlying engine used by Docker to build images ● img provides a standalone frontend for BuildKit ● buildah builds OCI images
  • 35. Multi-stage build Docker > 17.5 //TODO: Explain multi-stage build here
  • 36. Storage use-cases and properties
  • 37. Storage Type Description Storage Fit Amount of data Latency Examples Block ● Presented to the operating system (OS) as a block device ● Suitable for applications that need full control of storage and operate at a low level on files bypassing the file system ● Also referred to as a Storage Area Network (SAN) ● Non-shareable, which means that only one client at a time can mount an endpoint of this type High performance, primary/secondary Med Very low Structured, transactional, Relational DBs. GlusterFS, iSCSI, Fibre Channel, Ceph RBD, OpenStack Cinder, Dell/EMC Scale.IO, VMware vSphere Volume, GCE Persistent Disk, Azure Disk, AWS EBS File ● Presented to the OS as a file system export to be mounted ● Also referred to as Network Attached Storage (NAS) ● Concurrency, latency, file locking mechanisms, and other capabilities vary widely between protocols, implementations, vendors, and scales. Capacity based secondary Low Trade-off latency for simplicity Unstructured, file backup, archival GlusterFS, RHEL NFS, NetApp NFS, Azure File, Vendor NFS, Vendor GlusterFS, Azure File, AWS EFS Object ● Accessible through a REST API endpoint ● Configurable for use in the OpenShift Container Platform Registry ● Applications must build their drivers into the application and/or container. Highly reliable, cloud-scale, primary/secondary High Low-med Unstructured, big-data analytics GlusterFS, Ceph Object Storage (RADOS Gateway), OpenStack Swift, Aliyun OSS, AWS S3, Google Cloud Storage, Azure Blob Storage, Vendor S3, Vendor Swift