Skip to content

Instantly share code, notes, and snippets.

@eginez
Last active August 12, 2021 02:17
Show Gist options
  • Save eginez/f4e8369d16af6eceacd661be6ea64cf1 to your computer and use it in GitHub Desktop.
Save eginez/f4e8369d16af6eceacd661be6ea64cf1 to your computer and use it in GitHub Desktop.
Docker global limits via croups

Create slice file to limit resources: /etc/systemd/system/docker.slice

[Unit]
Description=Slice with MemoryLimit of 80% for docker
Before=slices.target

[Slice]
MemoryAccounting=true
MemoryMax=10%

Edit the docker config file: /etc/docker/daemon.json

{
    "cgroup-parent": "docker.slice",
    "exec-opts": ["native.cgroupdriver=systemd"]
}

Restart the services

sudo systemctl daemon-reload; sudo systemctl restart docker;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment