setting up xfs quotas with docker

requirements

XFS or EXT4 is required for OverlayFS2 though XFS has an advantage: you can specify a max file-system size for the container. you need to enable quota for that matter.

mkfs.xfs /dev/nvme0n1p3
vi /etc/fstab

/dev/nvme0n1p3  /docker xfs defaults,noatime,nodiratime,prjquota 0 2

mkdir /docker/
touch /docker/XFS_NOT_MOUNTED
mount /docker/
#rm -rf /var/lib/docker/
ln -s ../../docker /var/lib/docker

setup

we define bridge rather than bridge IP as it sets both gateway and cidr. we want instances to survive daemon down-time and even a host system reboot, hence we enable live-restore. and we’re giving a try to no-new-privileges.

vi /etc/docker/daemon.json # new file

{
    "bridge":               "br0",
    "data-root":        "/docker",
    "debug":        false,
    "exec-opts": [
                "native.cgroupdriver=cgroupfs"
    ],
    "ip-masq":      false,
    "iptables":     false,
    "ip6tables":        false,
    "live-restore":     true,
    "log-level":        "warn",
    "no-new-privileges":    true,
    "storage-driver":   "overlay2",
    "storage-opts": [
                "overlay2.size=5G"
    ]
}

moar options

# "bip": "",
# "dns": [],
# "dns-search": [],
# "hosts": [],
# "ipv6": false,

by default you get an hosts file with instance’s IP only and same resolv.conf as on the host.

acceptance

test xfs prjquota

as user

    docker run -d --name devuan --hostname devuan --workdir /root pbraun9/devuan

    docker exec -ti devuan /bin/bash

    df -h

resources

How to Enable Disk Quotas on an XFS File System https://www.thegeekdiary.com/how-to-enable-disk-quotas-on-an-xfs-file-system/

Docker Per-Container Disk Quota on Bind Mounted Volumes https://stackoverflow.com/questions/57248180/docker-per-container-disk-quota-on-bind-mounted-volumes

Storage quota per container - overlay2 backed by xfs https://forums.docker.com/t/storage-quota-per-container-overlay2-backed-by-xfs/37653

Docker Container Size Quota https://reece.tech/posts/docker-container-size-quota/

storage misc

About storage drivers https://docs.docker.com/storage/storagedriver/

Docker storage drivers https://docs.docker.com/storage/storagedriver/select-storage-driver/

Use the OverlayFS storage driver https://docs.docker.com/storage/storagedriver/overlayfs-driver/

Storage Drivers in Docker: A Deep Dive https://integratedcode.us/2016/08/30/storage-drivers-in-docker-a-deep-dive/

Docker Issues and Tips (aufs/overlay/btrfs..) https://github.com/AkihiroSuda/issues-docker

BTRFS vs OverlayFS https://www.reddit.com/r/docker/comments/5m4yhi/btrfs_vs_overlayfs/

storage advanced

how to clean up docker overlay directory? https://stackoverflow.com/questions/31712266/how-to-clean-up-docker-overlay-directory


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun