Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Quota for single Docker containers #7

Open
Sengorius opened this issue Feb 6, 2021 · 0 comments
Open

Adding a Quota for single Docker containers #7

Sengorius opened this issue Feb 6, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Sengorius
Copy link
Owner

Goal is to limit the amount of data that is not in the layers of base image, but in the diff of a Docker container.

A goad attempt can be found here: https://stackoverflow.com/questions/29029326/how-to-define-a-disk-quota-for-docker-containers
This one may fit in the DockerExec.

do_enable_quota() {
    local ID=$1
    local QUOTA_MB=$2

    local LOOPBACK=/var/lib/docker/aufs/diff/$ID-loopback
    local LOOPBACK_MOUNT=/var/lib/docker/aufs/diff/$ID-loopback-mount
    local DIFF=/var/lib/docker/aufs/diff/$ID

    docker stop -t=0 $ID
    sudo dd of=$LOOPBACK bs=1M seek=$QUOTA_MB count=0
    sudo mkfs.ext4 -F $LOOPBACK
    sudo mkdir -p $LOOPBACK_MOUNT
    sudo mount -t ext4 -n -o loop,rw $LOOPBACK $LOOPBACK_MOUNT
    sudo rsync -rtv $DIFF/ $LOOPBACK_MOUNT/
    sudo rm -rf $DIFF
    sudo mkdir -p $DIFF
    sudo umount $LOOPBACK_MOUNT
    sudo rm -rf $LOOPBACK_MOUNT
    sudo mount -t ext4 -n -o loop,rw $LOOPBACK $DIFF
    docker start $ID    
}
@Sengorius Sengorius added the enhancement New feature or request label Feb 6, 2021
@Sengorius Sengorius self-assigned this Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant