Skip to content

Latest commit

 

History

History
263 lines (201 loc) · 4.4 KB

storage_and_volume.md

File metadata and controls

263 lines (201 loc) · 4.4 KB

Storage and Volumes (10% of exam)

Content may include the following:

  • State which graph driver should be used on which OS
  • Demonstrate how to configure devicemapper
  • Compare object storage to block storage, and explain which one is preferable when available
  • Summarize how an application is composed of layers and where those layers reside on the filesystem
  • Describe how volumes are used with Docker for persistent storage
  • Identify the steps you would take to clean up unused images on a filesystem, also on DTR
  • Demonstrate how storage can be used across cluster nodes

Questions:

What is the pluggable architecture that Docker supports for the container writable layer storage?

Storage Drivers

What is the preferred storage driver for all Linux distributions which need no extra configuration?

Overlay2

Which device-mapper driver is used for production environments?

direct-lvm

Which device-mapper driver is used for testing environments?

loopback-lvm

How do you check the current storage driver information?

docker info

How do you configure device-mapper?

// stop docker
sudo systemctl stop docker
// set the device-mapper in /etc/docker/daemon.json file
{
  "storage-driver": "devicemapper"
}
//start docker
sudo systemctl start docker

what is the option that sets the direct-lvm for production device-mapper?

dm.directlvm_device

What do you set the device-mapper and all configurable options in the daemon.json?

{
  "storage-driver": "devicemapper",
  "storage-opts": [
    "dm.directlvm_device=/dev/xdf",
    "dm.thinp_percent=95",
    "dm.thinp_metapercent=1",
    "dm.thinp_autoextend_threshold=80",
    "dm.thinp_autoextend_percent=20",
    "dm.directlvm_device_force=false"
  ]
}

What are the different available storage options available for containers?

Block Storage
FiLE System Storage
Object Storage

Do containers create a writable layer on top of Image read-only layers?

Yes

Where is the Docker’s local storage area?

/var/lib/docker/<storage-driver>

What is the difference between bind mounts and volumes?

Volumes are completely managed by docker
Bind Mounts are dependent on the host directory structure

Volumes don’t increase the size of the containers. Is this statement correct and why?

Yes. Because volumes live outside of containers

Volumes don’t increase the size of the containers. Is this statement correct and why?

Volumes

How to create a Volume?

docker volume create my-volume

How to list docker volumes?

docker volume ls

How to inspect docker volume?

docker volume inspect my-vol

How to remove docker volumes?

docker volume rm my-vol

If you start a container with a volume that does not yet exist, Docker creates the volume for you. Is this statement correct?

Yes

How to create a volume myvol2 with a docker run?

docker run -d \
  --name devtest \
  -v myvol2:/app \
  nginx:latest

How to verify the volume is created with the container?

// Look for the mounts section
docker inspect devtest

How to create a volume with the --mount flag?

docker run -d \
  --name devtest \
  --mount source=myvol2,target=/app \
  nginx:latest

How to remove all unused images not just dangling images?

docker system prune --all