Skip to content

Instantly share code, notes, and snippets.

@marabesi
Forked from jpcaparas/References
Created April 15, 2020 08:27
Show Gist options
  • Save marabesi/6a4e6b969d259c9e0ded7605b77635ef to your computer and use it in GitHub Desktop.
Save marabesi/6a4e6b969d259c9e0ded7605b77635ef to your computer and use it in GitHub Desktop.
Limit docker CPU and memory resource usage
systemctl daemon-reload
systemctl restart docker
# /etc/docker/daemon.json
{
"cgroup-parent": "limit-docker-resource.slice"
}
# /etc/systemd/system/limit-docker-resource.slice
[Unit]
Description=Throttle CPU usage to 70% and memory usage to 8GB for docker-spawned processes
Before=slices.target
[Slice]
CPUQuota=70%
MemoryAccounting=true
MemoryLimit=8G
Inspired by: https://stackoverflow.com/questions/46408673/docker-17-06-ce-default-container-memory-limit-on-shared-host-resources/46557336#46557336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment